akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define MOD 998244353LL
int main(){
    long long n,bc=1LL,cc=1LL,ans=1LL;
    cin>>n;
    vector<long long>d(n);
    for(int i=0;i<n;i++)cin>>d[i];
    if(d[0]!=0LL){cout<<0<<endl;return 0;}
    sort(d.begin(),d.end());
    for(int i=1;i<n;i++){
        //cout<<d[i]<<endl;
        if(d[i]==0LL){cout<<0<<endl;return 0;}
        if(d[i-1]!=d[i]){
            if(d[i-1]+1LL!=d[i]){cout<<0<<endl;return 0;}
            bc=cc;
            cc=1LL;
        }
        else cc++;
        ans*=bc;
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF (9e18)
#define int ll
#define EPS (1e-6)
#define DB(x) #x<<":"<<x<<" "
#define debug(...) do{\
	cerr<<__PRETTY_FUNCTION__<<" - "<<__LINE__<<\
	" : ("#__VA_ARGS__<<") = ";\
	_OUT(__VA_ARGS__);\
}while(0)
using namespace std;
using ll=long long;
using pii=pair<int,int>;
template<typename T>void _OUT(T x){cerr<<x<<endl;}
template<typename T,typename...I>void _OUT(T x,I ...tail){cerr<<x<<", ";_OUT(tail...);}

void INIT(){
#ifdef LOCAL_TEST
	freopen("D:\\input.in","r",stdin);
	freopen("D:\\output.out","w",stdout);
	freopen("D:\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
}

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	b%=MOD;
	int ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int a[100010];
pii b[100010];
int c[100010];

int32_t main() {
	INIT();
	//code...
	int n,m; cin>>n>>m;
	For(i,0,n-1) cin>>a[i];
	For(i,0,m-1) cin>>b[i].S>>b[i].F;
	sort(a,a+n); reverse(a,a+n);
	sort(b,b+m); reverse(b,b+m);
	int tot=0;
	int i=0;
	for(;tot<n && i<m;i++){
		b[i].S=min(b[i].S,n-tot);
		tot+=b[i].S;
	}
	i--;
	For(j,0,n-1){
		if(j<n-tot) c[j]=0;
		else{
			c[j]=b[i].F;
			b[i].S--;
			if(b[i].S==0) i--;
		}
	}
	int ans=0;
	For(j,0,n-1) ans+=max(a[j],c[j]);
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 3328
import java.util.Scanner;

class Main {
  static long gcd(long x, long y) {
    if (y == 0) return x;
    else return gcd(y, x % y);
  }

  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    long a = Integer.parseInt(stdIn.next());
    long b = Integer.parseInt(stdIn.next());
    long ans = a * b / gcd(a, b);

    System.out.println(ans);
  }
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s=="SUN")
	{
		cout<<7;
		return 0;
	}
	else if(s=="MON")
	{
		cout<<6;
		return 0;
	}
	else if(s=="TUE")
	{
		cout<<5;
		return 0;
	}
	else if(s=="WED")
	{
		cout<<4;
		return 0;
	}
	else if(s=="THU")
	{
		cout<<3;
		return 0;
	}
	else if(s=="FRI")
	{
		cout<<2;
		return 0;
	}
	else if(s=="SAT")
	{
		cout<<1;
		return 0;
	}
 } 

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    char s[15], m[10] = "YAKI";
    int i;

    scanf("%s", s);

    for (i = 0; i < 4; i++)
    {
        if (s[i] != m[i])
        {
            printf("No");
            return 0;
        }
    }
    printf("Yes");

    return 0;
}

Measured memory_bytes: 128
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i,j,k;
ll c[10][10];
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>m;
  ll ans = 0;
  rep(i,10) rep(j,10) cin>>c[i][j];
  rep(k,10) rep(i,10) rep(j,10) if(c[i][j] > c[i][k] + c[k][j]) c[i][j] = c[i][k] + c[k][j];
  rep(i,n) rep(j,m){
    cin>>v;
    if(v >= 0) ans += c[v][1];
  }
  cout<<ans<<endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fr(i,c,b) for(int i=c;i<b;i++)
#define si(x) int x; scanf("%d", &x)
#define sll(x) ll x; scanf("%lld", &x)
#define pi(x) printf("%d", x)
#define pll(x) printf("%lld", x)
#define nl printf("\n")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define MAX 1000001

typedef long long int ll;

using namespace std;

int main()
{
    si(n);
    string s;
    cin>>s;
    string ans;
    ans=s[0];
    fr(i,1,n)
    {
        if(ans[ans.length()-1]!=s[i])
            ans+=s[i];
    }
    cout<<ans.length();
}

Measured memory_bytes: 512
#include <stdio.h>

int main()
{
	int N;
	scanf("%d", &N);
	
	int x[N];
	int i;
	int min = 1000000000;
	int MAX = 0;
	int temp;
	for(i = 0; i < N; i++){
		scanf("%d", &x[i]);
		temp = x[i];
		
		if(MAX < temp){
			MAX = temp;
		}
		if(min > temp){
			min = temp;
		}
	}
	
	printf("%d", MAX - min);
		
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int N=3005,M=1e9+7;
int n,m,x,y,f[N],a[N],r[N];
char s[N];
int main(){
	scanf("%d%d",&n,&m);
	scanf("%s",s+1);
	for (int i=1;i<=n;i++)r[i]=i,a[i]=a[i-1]+(s[i]=='1');
	while (m--){
		scanf("%d%d",&x,&y);
		r[x]=max(r[x],y);
	}
	f[0]=1;
	for (int i=1,R=0;i<=n;i++){
		R=r[i]>R?r[i]:R;
		for (int j=a[R]<i?a[R]:i;j>=0;j--)
			if (j<a[R]-R+i)f[j]=0;
			else if (j)(f[j]+=f[j-1])%=M;
	}
	printf("%d\n",f[a[n]]);
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <ctime>
#include <unordered_map>
#include <iomanip>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()

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

template<class T> ostream& operator<<(ostream& stream, const vector<T> v){ stream << "["; for (int i=0; i<(int)v.size(); i++) cout << v[i] << " "; stream << "]"; return stream; }
ll fpow(ll x, ll p, ll m){ll r=1; for (;p>>=1;){ if (p&1) r=r*x%m; x=x*x%m; } return r;}
int gcd(int a, int b){ if (!b) return a; return gcd(b,a%b);}
ll gcd(ll a, ll b){ if (!b) return a; return gcd(b,a%b);}

string s;

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

    int cr=0,i;
    cin >> s;
    for (i=0; i<(int)s.length()-1; i++)
        if (s[i]=='A' && s[i+1]=='C')
            cr=1;

    cout << (cr==1 ? "Yes" : "No\n");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <functional>
#include <sstream>
#include <complex>
#include <climits>
using namespace std;

#define REP(i,a,n) for(int i=(a);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define EPS 1e-8

int num[10];
int check[10];
vector<int> v;

bool solve(){
	int k;
	for(k=1; k<=9 && num[k]==0; k++);
	if( k==10 ){
		return true;
	}
	REP(i,1,10)if( num[i]>0 ){
		if( i<=7 && num[i]>0 && num[i+1]>0 && num[i+2]>0 ){
			num[i]--; num[i+1]--; num[i+2]--;
			if( solve() ) return true;
			num[i]++; num[i+1]++; num[i+2]++;
		}else if( num[i]>=3 ){
			num[i] -= 3;
			if( solve() ) return true;
			num[i] += 3;
		}
	}
	return false;
}

int main(){
	string in;
	int tmp[10];
	while(cin>>in){
		v.clear();
		rep(i,10)check[i]=num[i]=0;
		rep(i,in.size())num[in[i]-'0']++;
		rep(i,10)if( num[i]>=4 )check[i]=1;
		rep(i,10)tmp[i]=num[i];
		
		REP(i,1,10)if( !check[i] ){
			rep(j,10)num[j]=tmp[j];
			num[i]++;
			REP(j,1,10)if( num[j]>=2 ){
				num[j]-=2;
				if( solve() ){ v.push_back(i); break; }
				num[j]+=2;
			}
			num[i]--;
		}
		//cout << v.size() << endl;
		
		if( v.size()>0 ){
			sort(all(v));
			rep(i,v.size()){
				if( i!=0 )putchar(' ');
				printf("%d",v[i]);
			}puts("");
		}else{
			puts("0");
		}
	}
	return 0;
}

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


using namespace std;

int main () {
  int N,M;
  cin>>N>>M;
  
  vector<vector<int>> vec(M,vector<int>(2));
  for (int i=0;i<M;i++) {
    for (int j=0;j<2;j++) {
      cin>>vec.at(i).at(j);
    }
  }
  
  vector<int> count(N);
  int a;
  for (int i=0;i<M;i++) {
    for (int j=0;j<2;j++) {
      a = vec.at(i).at(j);
      count.at(a-1)++;
    }
  }
  for (int i=0;i<N;i++) {
    cout<<count.at(i)<<endl;
  }
    
    
}

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

using namespace std;

int main()
{
    double W;
    double H;
    double x;
    double y; 
    cin >> W >> H >> x >> y ;
    cout << W*H/2<< " " ;
    if(W==x*2 && H==y*2){
        cout << 1;
    }else{
        cout << 0;
    }
}

Measured memory_bytes: 256
N=int(input())
li=[]
for i in range(N):
    x,l=map(int,input().split())
    li.append((x-l,x+l))
li.sort(key=lambda x:x[1])
cnt=0;now=-(10**10);i=0
for i in range(N):
    if(now<=li[i][0]):
        cnt+=1
        now=li[i][1]
print(cnt)

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

vector<P> tell[15];

int main() {
    int n;
    cin >> n;
    rep(i,n) {
        int a;
        cin >> a;
        rep(j,a) {
            int x, y;
            cin >> x >> y;
            x--;
            tell[i].emplace_back(x,y);
        }
    }
    int ans = 0;
    rep(is,1<<n) {
        int cnt = __builtin_popcount(is);
        bool ok = true;
        rep(i,n) {
            if (!(is>>i&1)) continue;
            for (auto p : tell[i]) {
                int x = p.first, y = p.second;
                if (!(int(is>>x&1) == y)) ok = false;
            } 
        }
        if (ok) ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int N = 210;

int main(){
	//freopen("in.txt","r", stdin);
	int a, b, c;
	while (~scanf("%d%d%d", &a, &b, &c))
	{
		int cnt = 0;
		while (!(a == b && b == c))
		{
			if ((a&1) || (b&1) || (c&1))	
				break;
			cnt++;
			int a1 = a>>1;
			int b1 = b>>1;
			int c1 = c>>1;
			a = b1 + c1;
			b = a1 + c1;
			c = a1 + b1;
		}
		if (a == b && b == c)
		{
			if ((a&1) || (b&1) || (c&1))
				cnt = 0;
			else
				cnt = -1;
		}
		printf("%d\n", cnt);
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	boolean[][] check;
	boolean[][] checkall;
	
	int[] dx = {-1, 0, 1, 0};
	int[] dy = {0, -1, 0, 1};
	int w, h;
	int[][] map;
	
	int countb, countw;
	
	void calc(int n, int x, int y) {
		if (n == 1) countb++;
		else if (n == -1) countw++;
		for (int i = 0; i < 4; i++) {
			if (x+dx[i] >= 0 && x+dx[i] < h &&
				y+dy[i] >= 0 && y+dy[i] < w &&
				!checkall[x+dx[i]][y+dy[i]]) {
				if (map[x+dx[i]][y+dy[i]] == 0) {
					checkall[x+dx[i]][y+dy[i]] = true;
					calc(n, x+dx[i], y+dy[i]);
				}
			}
		}
	}
	
	
	boolean isB(int x, int y) {
		boolean flag = false;
		for (int i = 0; i < 4; i++) {
			if (x+dx[i] >= 0 && x+dx[i] < h &&
				y+dy[i] >= 0 && y+dy[i] < w &&
				!check[x+dx[i]][y+dy[i]]) {
				check[x+dx[i]][y+dy[i]] = true;
				if (map[x+dx[i]][y+dy[i]] == 1) return true;
				if (map[x+dx[i]][y+dy[i]] == 0) flag = flag || isB(x+dx[i], y+dy[i]);
			}
		}
		return flag;
	}
	
	boolean isW(int x, int y) {
		boolean flag = false;
		for (int i = 0; i < 4; i++) {
			if (x+dx[i] >= 0 && x+dx[i] < h &&
				y+dy[i] >= 0 && y+dy[i] < w &&
				!check[x+dx[i]][y+dy[i]]) {
				check[x+dx[i]][y+dy[i]] = true;
				if (map[x+dx[i]][y+dy[i]] == -1) return true;
				if (map[x+dx[i]][y+dy[i]] == 0) flag = flag || isW(x+dx[i], y+dy[i]);
			}
		}
		return flag;
	}
	
	void run() {
		while (true) {
			w = sc.nextInt(); h = sc.nextInt();
			sc.nextLine();
			if (w == 0) break;
			map = new int[h][w];
			for (int i = 0; i < h; i++) {
				String s = sc.nextLine();
				for (int j = 0; j < w; j++) {
					if (s.charAt(j) == '.')
						map[i][j] = 0;
					else if (s.charAt(j) == 'B')
						map[i][j] = 1;
					else
						map[i][j] = -1;
				}
			}
			
			
			check = new boolean[h][w];
			checkall = new boolean[h][w];
			countb = countw = 0;
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++){
					if (!checkall[i][j] && map[i][j] == 0) {	
						boolean b, w;
						for (int k = 0; k < h; k++) Arrays.fill(check[k], false);
						check[i][j] = true;
						b = isB(i, j);
						for (int k = 0; k < h; k++) Arrays.fill(check[k], false);
						check[i][j] = true;
						w = isW(i, j);
						checkall[i][j] = true;
						if (b && !w) {
							calc(1, i, j);
						} else if (!b && w) {
							calc(-1, i, j);
						} else {
							calc(0, i, j);
						}
					}
				}
			}
			
			out.printf("%d %d\n", countb, countw);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

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

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  int N; cin>>N;
  vector<int> d(N);
  REP(i,N) cin>>d[i];
  int ans = 0;
  if(N % 2 == 0) {
    sort(d.begin(), d.end());
    int a = d[N/2-1];
    int b = d[N/2];
    ans =	b-a;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define debug(...) cerr<<__LINE__<<" ["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec)
    { for (auto v : vec) os << v << ' '; os << '\n'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
    { os << '(' << pa.first << ',' << pa.second << ')'; return os; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T)
    { cerr << " " << H; debug_out(T...); }
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    string s;
    cin >> s;
    string S[7] = {"SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"};
    rep(i, 7) {
        if (S[i] == s) {
            cout << i + 1 << endl;
            return;
        }
    }
}

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


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
bool result(int x, int y, int z, int e){
	return ((x*x+z*z+y*y+x*y+y*z+z*x) <= e);
}
int main()
{
	int n, k;
	cin>>n>>k;
	long *arr = new long[n];
	for(int x = 0; x < n; x++)
		cin>>arr[x];

	sort(arr, arr+n);
	for(int x = 1; x < k; x++)
		arr[0]+=arr[x];

	cout<<arr[0]<<endl;

	return 0;
}


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

using namespace std;

typedef long long ll;
const int maxn = (int) 1e5 + 1;
const int N = 20000000;

int n, k;
ll a, ans = 1e18;
ll b[maxn], c[maxn];
int s;
vector < ll > h, g;
int main(){
    cin >> n >> k;
    for(int i = 1; i <= n; i++){
        cin >> a;
        if(a >= 0){
            h.push_back(a);
        }else {
            g.push_back(-a);
        }
        b[i] = 1e18;
        c[i] = 1e18;
    }
    b[0] = 1e18;
    c[0] = 1e18;
    sort(g.begin(), g.end());
    s = k;
    for(int i = 0; i < h.size(); i++){
        s--;
        if(s <= (int)g.size() && s > 0){
            b[i] = (g[s - 1] * 2) + h[i];
        }
        else if(s == 0){
            b[i] = h[i];
        }
    }
    s = k;
    for(int i = 0; i < g.size(); i++){
        s--;
        if(s <= (int)h.size() && s > 0){
            c[i] = (h[s - 1] * 2) + g[i];
        }
        else if(s == 0){
            c[i] = g[i];
        }
    }
    for(int i = 0; i < max((int)h.size(), (int)g.size()); i++){
        if(i < (int)h.size()){
            ans = min(ans, b[i]);
        }
        if(i < (int)g.size()){
            ans = min(ans, c[i]);
        }
    }
    cout << ans;
}


Measured memory_bytes: 3192
N=int(input())
A=list(map(int,input().split()))
if N==1:
  print(0)
  exit()
if N==2:
  print(abs(A[0]-A[1]))
  exit()
dp=[0]*N
dp[1]=abs(A[1]-A[0])
i=2
while i<N:
  dp[i]=min(abs(A[i]-A[i-1])+dp[i-1],abs(A[i]-A[i-2])+dp[i-2])
  i+=1
print(dp[-1])

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

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

    int p;
    double max = 0.0;
    double current = 0.0;
    std::queue<double> queue;
    for (int i = 0; i < N; ++i) {
        std::cin >> p;
        const double e = 1.0 / 2.0 * (p + 1);
        current += e;
        queue.push(e);

        if (i == (K-1)) {
            max = current;
        } else if (i > (K-1)) {
            const double v = queue.front(); queue.pop();
            current -= v;
            max = std::max(max, current);
        }
    }

    std::printf("%.10lf\n", max);

    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
typedef pair<int,int>P;
 
int main() {
  ll a,b,c;
  cin>>a>>b>>c;
  for(int i=0;i<b;i++){
    cout<<c<<" ";
  }
 for(int j=0;j<a-b;j++){
     if(c>2){
     cout<<c-1<<" ";
     }
     else{
       cout<<c+1<<" ";
     }
 }
}


Measured memory_bytes: 1280
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    ll a=in(),b=in(),k=in();
    cout<<max(a-k,0ll)<<' '<<max(b-max(k-a,0ll),0ll)<<endl;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1001001001;
static const ll MOD = 1000000007;
const int n = 13;
ll dp[100005][n];

int main() {
    string s;
    cin >> s;
    dp[0][0] = 1;
    for (int i = 0; i < s.size(); i++) {
        char c = s[i];
        if (c == '?') {
            for (int k = 0; k < 10; k++) {
                for (int j = 0; j < n; j++) {
                    dp[i + 1][(j * 10 + k) % n] += dp[i][j];
                    dp[i + 1][(j * 10 + k) % n] %= MOD;
                }
            }
        } else {
            int k = c - '0';
            for (int j = 0; j < n; j++) {
                dp[i + 1][(j * 10 + k) % n] += dp[i][j];
                dp[i + 1][(j * 10 + k) % n] %= MOD;
            }
        }
    }

    cout << dp[s.length()][5] << endl;

}


Measured memory_bytes: 10624
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int main(){

    int n,i;
    cin >> n >> i;
    cout << n-i+1 << endl;



    return 0;
}

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

#define pb push_back
#define mp make_pair

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

int a, b;

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

	if(a * 2 <= b && b <= a * 4 && b % 2 == 0){
		puts("Yes");
	} else {
		puts("No");
	}

	return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int L, R, d;
    cin >> L >> R >> d;
    int cnt = 0;
    rep2(i, L, R) if(i%d == 0) cnt++;
    cout << cnt << endl;
}

Measured memory_bytes: 3588
import java.util.Scanner;

public class Main {

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

	    long N = Integer.parseInt(scanner.next());
	    long[] A = new long[100001];

	    for (long i = 0; i < N; i++) {
	        int index = Integer.parseInt(scanner.next());
	        A[index]++;
	    }

	    int Q = Integer.parseInt(scanner.next());
	    long sum = 0;
	    for (int i = 0; i < A.length; i++) {
	        sum += (long)i * A[i];
	    }

	    for (int i = 0; i < Q; i++) {
	        int B = Integer.parseInt(scanner.next());
	        int C = Integer.parseInt(scanner.next());
	        sum += (long)(C - B) * A[B];
	        A[C] += A[B];
	        A[B] = 0;
		    System.out.println(sum);
	    }
	}
}

Measured memory_bytes: 61260
#AGC032
b = input()
ans = 0
kari = 0
flag = True
for i in range(len(b)):
    #print(b[i])
    if b[i] == "A" or b[i] == "T" or b[i] == "C" or b[i] == "G":
        if flag == True:
            kari += 1
            ans = max(kari,ans)
        else:
            kari = 1
            ans = max(kari,ans)
        flag = True
    else:
        
        flag = False
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

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

		int N = sc.nextInt();
		int[] arr = new int[N];
		long[] con_arr = new long[N + 1];
		long all = 0;

		for (int i = 0; i < N; i++) {
			int let = sc.nextInt();
			arr[i] = let;
			con_arr[let]++;
		}

		for (int i = 1; i < N + 1; i++) {
			if (con_arr[i] > 0) {
				all += con_arr[i] * (con_arr[i] - 1) / 2;
			}
		}

		for (int i = 0; i < arr.length; i++) {
			int bannd = arr[i];
			System.out.println(all - (con_arr[bannd] - 1));
		}
	}
}

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

using namespace std;

int main(void)
{
    int N;
    cin >> N;
    vector<int>A(N);
    vector<int> B(N-1);
    for(int i = 0; i < B.size(); i++){
        cin >> B[i];
    }

    int sum = B[0];
    for(int i = 1; i < N-1; i++){
        sum += min(B[i-1], B[i]);
    }
    sum += B[N-2];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>

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

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

    int q;
    std::cin >> q;
    for (int i = 0; i < q; i++) {
        int k;
        std::cin >> k;
        auto position = std::lower_bound(A.begin(), A.end(), k);
        std::cout << std::distance(A.begin(), position) << std::endl;
    }
}



Measured memory_bytes: 3128
# -*- coding: utf-8 -*-
"""



"""
import sys


def solve(A, P):
    P += A * 3
    return P // 2


def main(args):
    A, P = map(int, input().split())
    ans = solve(A, P)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 2940
X, Y = map(int, input().split())
mod = 10 ** 9 + 7


# nCr フェルマーの小定理より（ABC156D参照）
def comb_mod(n, r, mod):
    num = 1
    den = 1
    for i in range(r):
        num = (num * (n - i)) % mod
        den = (den * (i + 1)) % mod
    den_r = pow(den, mod - 2, mod)
    return (num * den_r) % mod


# n+2m=X,2n+m=Yより
n = (2 * Y - X) // 3
m = (2 * X - Y) // 3

# 3の倍数以外は0
# (0,6)など、n<0 or m<0のときも0
if (X + Y) % 3 != 0 or n < 0 or m < 0:
    print(0)
else:
    print(comb_mod(n + m, n, mod))


Measured memory_bytes: 3188
#include <stdio.h>

int main(void){

	int n,m,l,i,j,k;

	scanf("%d %d %d",&n,&m,&l);
	long long int a[n][m],b[m][l],c[n][l],term;
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%lld",&a[i][j]);
		}
	}
	for(i=0;i<m;i++){
		for(j=0;j<l;j++){
			scanf("%lld",&b[i][j]);
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
    		c[i][j]=a[i][j]*b[i][j];
			term=0;
			for(k=0;k<m;k++){
				term=term+a[i][k]*b[k][j];
			}
			c[i][j]=term;
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
		    if(j>0) printf(" ");
	        printf("%lld",c[i][j]);
		}
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 2104
while True:
    a,op,b=input().split()
    if op == "+":
        print(int(a)+int(b))
    elif op == "-":
        print(int(a)-int(b))
    elif op == "*":
        print(int(a)*int(b))
    elif op == "/":
        print(int(a)//int(b))
    else:
        break


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

int main(void){
  int n;
  cin>>n;
  
  switch(n%10){
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      cout<<"hon"<<endl;
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      cout<<"pon"<<endl;
      break;
    case 3:
      cout<<"bon"<<endl;
      break;
  }
  return 0;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;

signed main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int r = 0, b = 0;
  rep(i, s.size()) {
    if (s[i] == 'R')
      r++;
    else
      b++;
  }
  cout << (r > b ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
#include<bitset>
#include<map>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')	f=-1;c=getchar();}
    while(isdigit(c))	{x=x*10+c-'0';c=getchar();}
    x*=f;
}
long long a,b;
int main()
{
	read(a);
	read(b);
	b/=a;
	int ans=0;
	while(b)
	{
		b>>=1;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(){
 
 
  int dataSets;
  cin >> dataSets;
  for(int i=0;i<dataSets;i++){
    double x1, y1, x2, y2, x3, y3, x4, y4;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
    if(abs((y2-y1)*(x4-x3) - (x2-x1)*(y4-y3)) < 0.0000000001){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
 
  }
 
  return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
    int N;
    string S;
    cin >> N >> S;
    vector<int> E(N), W(N);
    if (S[0] == 'E')
    {
        E[0] = 1;
        W[0] = 0;
    }
    else
    {
        E[0] = 0;
        W[0] = 1;
    }
    for (int i = 1; i < N; ++i)
    {
        if (S[i] == 'E')
        {
            E[i] = E[i - 1] + 1;
            W[i] = W[i - 1];
        }
        else
        {
            E[i] = E[i - 1];
            W[i] = W[i - 1] + 1;
        }
    }
    int ans = E[N - 1] - E[0];
    for (int i = 0; i < N; ++i)
    {
        int toE, toW;
        if (i == 0)
        {
            toE = 0;
        }
        else
        {
            toE = W[i - 1];
        }
        if (i == N - 1)
        {
            toW = 0;
        }
        else
        {
            toW = E[N - 1] - E[i];
        }
        ans = min(ans, toE + toW);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6148
N=int(input())
S=input()
flag="-1"
l=[]
b=0
w=0
for i in range(N):
    if S[i]=="#":
        if flag=="w":
            l.append([b,w])
            b=1
            w=0
            flag="b"
        else:
            flag="b"
            b+=1
    else:
        if flag=="b":
            w+=1
            flag="w"
        elif flag=="-1":
            continue
        else:
            flag="w"
            w+=1
if flag=="w":
    l.append([b,w])

aw=0
ab=0
for i in range(len(l)):
    aw+=l[i][0]
    ab+=l[i][1]
ans=[]
ans.append(aw)
ans.append(ab)
tmpw=0
tmpb=0
val=0
for i in range(len(l)):
    tmpw+=l[i][1]
    tmpb+=l[i][0]
    val=(ab-tmpw)+tmpb
    ans.append(val)
print(min(ans))

Measured memory_bytes: 57292
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

ll dat[10200];
bool yatta[5000];

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


	int N, K;
	cin >> N >> K;
	int P[5000], C[5000];
	rep(i, N) {
		cin >> P[i];
		P[i]--;
	}
	rep(i, N) {
		cin >> C[i];
	}

	ll kotae = -2e18;
	rep(i, N) if (!yatta[i]) {
		int L = 0;
		auto kari = dat;
		kari[0] = 0;
		int j = i;
		while (!yatta[j]) {
			yatta[j] = 1;
			kari[L + 1] = kari[L] + C[j];
			L++;
			j = P[j];
		}
		ll hue = kari[L];
		for (int j = L + 1; j <= L + L; j++) {
			kari[j] = kari[j - L] + hue;
		}
		ll amari = K % L;
		ll wari = K / L;
		ce(hue);
		if (hue > 0) {
			if (amari > 0) {
				deque<int> dq;
				rep1(i, L + amari - 1) {
					while (dq.size() && kari[dq.back()] <= kari[i]) dq.pop_back();
					dq.push_back(i);
					if (i < amari) continue;
					while (dq.size() && dq.front() <= i - amari) dq.pop_front();
					chmax(kotae, hue * wari + kari[dq.front()] - kari[i - amari]);
					ce(kari[dq.front()]);
				}
			}			
			if (wari > 0) {
				deque<int> dq;
				rep1(i, L + L - amari - 1) {
					while (dq.size() && kari[dq.back()] <= kari[i + amari]) dq.pop_back();
					dq.push_back(i + amari);
					if (i < L - amari) continue;
					while (dq.size() && dq.front() <= i + amari - L) dq.pop_front();
					chmax(kotae, hue * (wari - 1) + kari[dq.front()] - kari[i + amari - L]);
					ce(kari[dq.front()]);
				}
			}
		}
		else {
			deque<int> dq;
			int are = min(K, L);
			rep1(i, L + are - 1) {
				while (dq.size() && kari[dq.back()] <= kari[i]) dq.pop_back();
				dq.push_back(i);
				if (i < are) continue;
				while (dq.size() && dq.front() <= i - are) dq.pop_front();
				chmax(kotae, kari[dq.front()] - kari[i - are]);
			}
		}
	}

	co(kotae);


	Would you please return 0;
}

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

int main(void){

    int N;cin>>N;

    double ans=0.0;
    for (int i = 0; i < N; ++i) {
        double x;
        string u;
        cin >>x>>u;
        if(u=="JPY"){
            ans += x;
        }else{
            ans+=380000.0*x;
        }
    }

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

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

if N%2 == 0:
  print(N, N, N//2)
else:
  for h in range(1, 3501):
    for n in range(1, 3501):
      num = N*h*n
      dem = 4*h*n - N*(h+n)
      if dem > 0 and num%dem == 0:
        print(h, n, num//dem)
        quit()

Measured memory_bytes: 40428
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,sum=0;
  cin>>a>>b;
  sum=a+b;
  if(sum>=10)
  cout<<"error"<<endl;
  else
  cout<<sum<<endl;
  sum=0;
  return 0;
} 

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define sp ' '
#define nyan "(=^・ω・^=)"
#define mkp make_pair
#define intmax 2147483647
#define llmax 9223372036854775807
#define lP pair<ll,ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;
const int mod = 1000000007;

int X1, X2, Y1, Y2;

int main() {
	cin >> X1 >> Y1 >> X2 >> Y2;
	cout << X2 - Y2 + Y1 << sp << Y2 + X2 - X1 << sp << X1 - Y2 + Y1 << sp << Y1 + X2 - X1 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws Exception {

        ModScanner ms = new ModScanner();
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        int n = ms.nextInt();
        int[][] input = new int[n][3];
        for (int i = 0; i < n; i++) {
            input[i][0] = ms.nextInt();
            input[i][1] = ms.nextInt();
            input[i][2] = ms.nextInt();
        }
        int[][] dp = new int[n][3];
        dp[0][0] = input[0][0];
        dp[0][1] = input[0][1];
        dp[0][2] = input[0][2];
        for (int i = 1; i < n; i++) {
            dp[i][0] = input[i][0] + Math.max(dp[i - 1][1], dp[i - 1][2]);
            dp[i][1] = input[i][1] + Math.max(dp[i - 1][0], dp[i - 1][2]);
            dp[i][2] = input[i][2] + Math.max(dp[i - 1][0], dp[i - 1][1]);
        }
        out.println(Math.max(dp[n - 1][0], Math.max(dp[n - 1][1], dp[n - 1][2])));
        out.close();
    }


}

class ModScanner {

    BufferedReader br;
    StringTokenizer st;

    public ModScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String nextToken() throws Exception {
        while (st == null || !st.hasMoreElements()) {
            st = new StringTokenizer(br.readLine());

        }
        return st.nextToken();
    }

    String nextString() throws Exception {
        return br.readLine();
    }


    int nextInt() throws Exception, Exception {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }

}


Measured memory_bytes: 61808
import java.math.*;
import java.text.*;
import java.lang.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = Integer.parseInt(in.nextLine());
		for(int i=0; i<n; i++){
			String s = in.nextLine();
			System.out.println(s.replaceAll("Hoshino", "Hoshina"));
		}
	}

}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)


bool can_reach(bool edge[51][51], int start, int end) {
  // startからendにたどり着けるか？
  queue<int> q;
  q.push(start);
  vector<bool> visited(51, false);
  while (!q.empty()) {
    int p = q.front(); q.pop();
    if (p == end)
      return true;
    if (visited[p])
      continue;
    visited[p] = true;
    REP(i, 51) {
      if (edge[p][i])
        q.push(i);
    }
  }
  return false;
}
int main() {
  // あるiとjを結ぶ橋は「消したとき、iとjの間にパスが存在しなくなる辺」のこと
  // ということは、辺を消してみて到達できなくなったらカウントとすればいい

  int N, M;
  cin >> N >> M;

  bool edge[51][51];
  REP(i, 51) {
    REP(j, 51) {
      edge[i][j] = false;
    }
  }
  REP(i, M) {
    int a, b;
    cin >> a >> b;
    edge[a][b] = edge[b][a] = true;
  }
  int bridge_count = 0;
  REP(i, N + 1) {
    FOR(j, i + 1, N + 1) {
      if (edge[i][j]) {
        edge[i][j] = edge[j][i] = false;
        if (!can_reach(edge, i, j))
          ++bridge_count;
        edge[i][j] = edge[j][i] = true;
      }
    }
  }

  cout << bridge_count << endl;
  return 0;
}


Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d %d", $n, $k);
#$inputs = array_map(function($x) { return (1+$x)/2;}, explode(" ", trim(fgets(STDIN))));
$inputs = array_map("intval", explode(" ", trim(fgets(STDIN))));

$cumsum = [0];
for ($i = 0; $n > $i; $i++) {
    $cumsum[$i+1] = $cumsum[$i] + $inputs[$i];
    #$cumsum[$i+1] = $cumsum[$i] + (1+$inputs[$i])/2;
}
#echo join(',', $cumsum) . "\n"; #debug

#累積和を出す（既に期待値になってる）
$x = -1;
for ($i = 1; $n - ($k - 1) >= $i; $i++) {
    $y = $cumsum[$i+$k-1] - $cumsum[$i-1];
    if ($x < $y) {
        $x = $y;
    }
}

printf("%f", ($x + $k) / 2);


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

int main() {
	string s, t;
	cin >> s >> t;
	int a = 0, b = 0;
	int n = s.size();
	int k = t.size();
	if (n > k) {
		rep(i, n + k) {
			if (i % 2 == 0) {
				cout << s[a];
				a++;
			}
			else {
				cout << t[b];
				b++;
			}
		}
	}
	if (n < k) {
		rep(i, n + k) {
			if (i % 2 != 0) {
				cout << s[a];
				a++;
			}
			else {
				cout << t[b];
				b++;
			}
		}
	}
	if (n == k) {
		rep(i, n + k) {
			if (i % 2 == 0) {
				cout << s[a];
				a++;
			}
			else {
				cout << t[b];
				b++;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm> 

using namespace std;

#define N 100001

bool ok[N];
int sum[N]; 

int main()
{
	int n,m,x,a=0,b=0;
	char c;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;++i)
	{
		scanf("%d",&x);
		scanf("%*c%c%*c",&c);
		if(ok[x]) continue;
		if(c=='A') ok[x]=true;
		else sum[x]++;
	}
	for(int i=1;i<=n;++i)
		if(ok[i]) a++,b+=sum[i];
	printf("%d %d",a,b);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  cin>>N;
  int count=0;
  int ans=0;
  if(N.at(0)!='A')
    ans=1;    
  for(int i=2;i<N.size()-1;i++){
    if(isupper(N.at(i))){
      if(N.at(i)=='C')
         count++;
      else
        ans=1;
    }
    if(ans==1)
       break;
  }
  if(count!=1)
    ans=1;
  if(isupper(N.at(N.size()-1))||isupper(N.at(1)))
    ans=1;
  if(ans==0)
    cout<<"AC"<<endl;
  else
    cout<<"WA"<<endl;
}
 
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define GIO ios_base::sync_with_stdio(0);cin.tie(0);

int main()
{ GIO;
    string s1,s2;
    int f=0;
    cin>>s1>>s2;
    for(int i=0;i<s2.length();i++)
    {
    	if(s1==s2)
    	{     f=1;
    		break;
    	}
    	char temp = s2[0];
    	int j;
       for (j = 0; j < s2.length()-1; j++)
       s2[j] = s2[j+1];
    
       s2[j] = temp;
    }
    if(f==1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    

return 0;
}

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

namespace AtTest.ABC_167
{
    class B
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            long[] abck = ReadLongs();
            long a = abck[0];
            long b = abck[1];
            long c = abck[2];
            long k = abck[3];

            long res = 0;
            if (a < k)
            {
                res += a;
                k -= a;

                if (b < k)
                {
                    k -= b;

                    if (k>0)
                    {
                        res -= k;
                    }
                }
            }
            else
            {
                res = k;
            }

            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

int main() {
  long long int n;
  cin >> n;
  long long int d[n+1];
  d[0] = 0;
  for(int i=1;i<=n;i++)
    cin >> d[i];
  sort(d, d + n+1);
  
  int i = 0;
  while(i<n/2)
    i++;
  cout << d[i+1] - d[i] << endl;
}

Measured memory_bytes: 1152
def main():
    from collections import defaultdict, deque
    import sys
    input = sys.stdin.readline

    N, M, K = map(int, input().split())

    g = tuple(set() for _ in range(N))
    direct_friend = [0] * N
    for _ in range(M):
        a, b = (int(x) - 1 for x in input().split())

        g[a].add(b)
        g[b].add(a)

        direct_friend[a] += 1
        direct_friend[b] += 1

    bk = tuple(set() for _ in range(N))
    for _ in range(K):
        c, d = (int(x) - 1 for x in input().split())
        bk[c].add(d)
        bk[d].add(c)

    dq = deque()
    checked = [-1] * N
    for v in range(N):
        if ~checked[v]:
            continue

        dq.append((v, v))  # v,root
        checked[v] = v
        while dq:
            v, root = dq.pop()
            for u in g[v]:
                if ~checked[u]:
                    continue
                checked[u] = root
                dq.append((u, root))

    ctr = defaultdict(int)
    for v in range(N):
        root = checked[v]
        ctr[root] += 1

    ret = []
    for v in range(N):
        root = checked[v]
        t = ctr[root] - direct_friend[v] - 1
        for u in bk[v]:
            if checked[u] == root:
                # 同じ連結成分に属するがブロック関係
                # for二重なので間に合わないと思っていたが総数K<=10**5で間に合う
                t -= 1
        ret.append(t)

    print(*ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 87272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;


int main(){
  ll N, K;
  cin>>N>>K;
  vector<ll> H(N);
  rep(i, N){
    cin>>H[i];
  }
  vector<ll> dp(N, INF);
  dp[0]=0;
  rep(i, N-1){
    rep(j, K){
      if(i-j>=0)dp[i+1]=min(dp[i+1], dp[i-j]+abs(H[i+1]-H[i-j]));
    }
  }
  cout<<dp[N-1]<<endl;
  return 0;
} 

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

typedef long long int   ll;
#define cases           int t;cin>>t;while(t--)
#define FIO             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl            "\n"
#define scan(n)         scanf("%d",&n)
#define mod             1000000007
#define maxn            200001
#define PI              3.1415926535897932384626433832795
#define int             ll
#define loop0           for(int i=0;i<n;i++)
#define loop1           for(int i=1;i<=n;i++)
#define inpar0(ar)      for(int i=0;i<n;i++)cin>>ar[i];
#define inpar1(ar)      for(int i=1;i<=n;i++)cin>>ar[i];
#define showar0(ar)     for(int i=0;i<n;i++)cout<<ar[i]<<" ";
#define showar1(ar)     for(int i=1;i<=n;i++)cout<<ar[i]<<" ";
#define manu            cout<<(checkerCounter++)<<endl;
static int checkerCounter = 1;
int binpow(int a,int b){int res=1;while(b>0){if(b%2){res=(res*a)%mod;b--;}a=(a*a)%mod;b/=2;}return res%mod;}
bool isPrime(int n){if(n==1)return false;for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}

int ans[maxn];
bool vis[maxn];
void bfs(int ch,vector<int> adj[]){
    queue<int> q;
    q.push(ch);
    while(!q.empty()){
        int x=q.front();
        vis[x]=true;
        q.pop();
        for(int i=0;i<adj[x].size();i++){
            if(vis[adj[x][i]]==false){
                vis[adj[x][i]]=true;
                q.push(adj[x][i]);
                ans[adj[x][i]]=x;
            }
        }
    }
}

signed main(){
    int n,m;cin>>n>>m;
    vector<int> adj[n+1];
    for(int i=0;i<m;i++){
        int u,v;cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    bfs(1,adj);
    bool ch=true;
    for(int i=1;i<=n;i++)ch&=vis[i];
    if(!ch){
        cout<<"No"<<endl;
    }else {
        cout<<"Yes"<<endl;
        for(int i=2;i<=n;i++)cout<<ans[i]<<endl;
    }
}


Measured memory_bytes: 13032
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>

typedef long long ll;
using namespace std;

int main()
{
    ll a,b;
    cin>>a>>b;
    ll c=a%b;
    if(c==0)
    {
        cout<<0<<endl;
        return 0;
    }
    else
    {
        ll x=b-c;
        ll mins=min(x,c);
        cout<<mins<<endl;
    }
    return 0;
}



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

using namespace std;
using ll = long long;

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

    int x, y;
    cin >> x >> y;

    if(y % 2 == 0 && y >= 2 * x && y <= 4 * x) printf("Yes\n");
    else printf("No\n");

    return 0;
}

Measured memory_bytes: 3640
Sa = list(input())
Sb = list(input())
Sc = list(input())
turn = "a"
while True:
	if turn == "a":
		if Sa == []:
			print("A")
			break
		else:
			x = Sa[0]
			Sa.remove(Sa[0])
		turn = x
	elif turn == "b":
		if Sb == []:
			print("B")
			break
		else:
			x = Sb[0]
			Sb.remove(Sb[0])
		turn = x
	else:
		if Sc == []:
			print("C")
			break
		else:
			x = Sc[0]
			Sc.remove(Sc[0])
		turn = x

Measured memory_bytes: 3064