akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static String g;
	static String[] a, b;
	static final int INF = 999;
	static int N, M, A, B, C, T, RT;

	public static void main(String[] args) {
		while (true) {
			N = sc.nextInt();
			if (N == 0) break;
			M = sc.nextInt();
			A = sc.nextInt();
			B = sc.nextInt();
			C = sc.nextInt();
			T = sc.nextInt();
			RT = (int) Math.sqrt(T);
			int[] ans = solve();
			for (int i = 0; i < N; ++i) {
				if (i != 0) System.out.print(" ");
				System.out.print(ans[i]);
			}
			System.out.println();
		}
	}

	static int[] solve() {
		int[] v = new int[N];
		for (int i = 0; i < N; ++i) {
			v[i] = sc.nextInt();
		}
		if (RT == 0) return v;
		int[][] count = new int[N + 2][N + 2];
		for (int i = 0; i < N; ++i) {
			int[][] c = new int[2][N + 2];
			c[0][i + 1] = 1;
			int t = 0;
			for (int j = 0; j < RT; ++j) {
				for (int k = 0; k < N; ++k) {
					c[1 - t][k + 1] = 0;
				}
				for (int k = 0; k < N; ++k) {
					c[1 - t][k] += c[t][k + 1] * C;
					c[1 - t][k + 1] += c[t][k + 1] * B;
					c[1 - t][k + 2] += c[t][k + 1] * A;
				}
				for (int k = 0; k < N; ++k) {
					c[1 - t][k + 1] %= M;
				}
				t = 1 - t;
			}
			for (int j = 0; j < N; ++j) {
				count[i + 1][j + 1] = c[t][j + 1];
			}
		}
		int[][] c = new int[2][N + 2];
		for (int i = 0; i < N; ++i) {
			c[0][i + 1] = v[i];
		}
		int t = 0;
		for (int i = 0; i < RT; ++i) {
			for (int j = 0; j < N; ++j) {
				c[1 - t][j + 1] = 0;
			}
			for (int j = 0; j < N; ++j) {
				for (int k = 0; k < N; ++k) {
					c[1 - t][k + 1] += c[t][j + 1] * count[j + 1][k + 1];
				}
			}
			for (int j = 0; j < N; ++j) {
				c[1 - t][j + 1] %= M;
			}
			t = 1 - t;
		}
		for (int i = RT * RT; i < T; ++i) {
			for (int j = 0; j < N; ++j) {
				c[1 - t][j + 1] = 0;
			}
			for (int j = 0; j < N; ++j) {
				c[1 - t][j] += c[t][j + 1] * C;
				c[1 - t][j + 1] += c[t][j + 1] * B;
				c[1 - t][j + 2] += c[t][j + 1] * A;
			}
			for (int j = 0; j < N; ++j) {
				c[1 - t][j + 1] %= M;
			}
			t = 1 - t;
		}
		for (int i = 0; i < N; ++i) {
			v[i] = c[t][i + 1];
		}
		return v;
	}
}

Measured memory_bytes: 35772
/**Hey, What's up?*/

#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
vector<long long>v;
int main()
{
    fastio;
    long long a=0,b=0,c,d,e,f=0,l,g,m,n,k,i,j,t,p,q;
    cin>>n;
    d=LLONG_MAX;
    for(i=0;i<n;i++){
        cin>>a;
        if(a<=d)f++;
        d=min(a,d);
    }
    cout<<f<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(x, max(y, z))
#define MIN(x, y, z) min(x, min(y, z))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  string S;
  cin >> S;
  ll N = S.size();
  rep(i, N + 1) {
    if (i == 0) continue;
    S.erase(S.end() - 1);
    if (S.size() % 2 == 1) continue;
    string a = S.substr(0, S.size() / 2);
    string b = S.substr((S.size() / 2), S.size() / 2);
    if (a == b) {
      COUT(S.size());
      return 0;
    }
  }
  return 0;
}

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

typedef long long ll;
typedef vector<vector<ll> > Adj_Mat;


bool contain(int mask, int pos){
	  return ( mask & (1<<pos) ) != 0;
}

int main(){

	  // Input Graph
	  int V,E;
	  cin >> V >> E;
	  Adj_Mat G(V,vector<ll>(V,INT_MAX));
	  for(int i=0; i<E; i++){
			int s,t,d; cin >> s >> t >> d;
			G[s][t] = d;
	  }

	  ll ans = INT_MAX;
	  // Dynamic Programming for TSP
	  for(int st=0; st<V; st++){

			ll dp[ (1<<V) ][ V ];
			for(int i=0; i<(1<<V); i++) for(int j=0; j<V; j++) dp[i][j] = INT_MAX;
			dp[ 0 ][ st ] = 0;

			for(int S=1; S<(1<<V); S++)
				  for(int v=0; v<V; v++)
						if( contain(S,v) )
							  for(int j=0; j<V; j++)
									dp[S][v] = min(dp[S][v], dp[S-(1<<v)][j] + G[j][v]);
			ans = min(ans,dp[(1<<V)-1][st]);
	  }
	  if( ans >= 1e+9 ) ans = -1;
	  cout << ans << endl;
}

Measured memory_bytes: 5044
import java.util.*;
public class Main{
  public static void main(String[] args) {
    int a,b,c;
    Scanner sc=new Scanner(System.in);
    a=sc.nextInt();
    b=sc.nextInt();
    c=sc.nextInt();
    if(a+b+c>=22){
      System.out.println("bust");
    }
    if(a+b+c<=21){
      System.out.println("win");
    }
  }
}


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

#define rep(n, i) for(int i = 0; i < n; i++)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

void solve(void){
    int n, q;
    scanf("%d\n", &n);
    int s[n];
    rep(n, i) scanf("%d ", &s[i]);
    scanf("\n");
    scanf("%d\n", &q);
    int t[q];
    rep(q, i) scanf("%d ", &t[i]);
    int bools[q];
    rep(q, i) bools[i] = binarysearch(t[i], s, n);
    int sum = 0;
    rep(q, i) sum += bools[i];
  printf("%d\n", sum);
}

int binarysearch(int a, int* xs, int len){
    if (len == 0) return 0;
    if (len == 1) {
        if (xs[0] == a) return 1; else return 0;
    }
    int mid = len / 2 + 1;
    int p = xs[mid-1];
    if (p == a) return 1;
    if (p > a) return binarysearch(a, &xs[0], mid - 1);
    else return binarysearch(a, &xs[mid], len - mid);
}

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

Measured memory_bytes: 2472
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
template <typename T> 
struct SegmentTree {
  
  int n;
  vector<T> node;

  T f(T a, T b) {return max(a, b);}
  void g(T &a, T b) {a = b;}

  SegmentTree (int sz, T init = 0) {
    n = 1; while (n < sz) n <<= 1;
    node.assign(2*n, init);
    for (int i = n - 2; i >= 0; i--) node[i] = f(node[2*i+1], node[2*i+2]);
  }

  void update(int k, T x) {
    k += (n - 1);
    g(node[k], x);
    while (k > 0) {
      k = (k - 1) >> 1;
      node[k] = f(node[2*k+1], node[2*k+2]);
    } 
  }

  T query(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    if (r <= a || b <= l) return 0;
    if (a <= l && r <= b) return node[k];
    T vl = query(a, b, 2*k+1, l, (l+r)/2);
    T vr = query(a, b, 2*k+2, (l+r)/2, r);
    return f(vl, vr);
  }

  T getvalue(int k) {
    return query(k,k+1);
  }

  template <typename F> 
  int find (int a, int b, T x, F &ok, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    if (l + 1 == r) return (ok(node[k]) ? k - n + 1 : b);
    if (!ok(node[k]) || r <= a || b <= l) return b;
    int vl = find(a, b, x, ok, 2*k+1, l, (l + r)/2);
    if (vl != b) return vl;
    return find(a, b, x, ok, 2*k+2, (l + r)/2, r);
  }
 
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, q;
  cin >> n >> q;
  SegmentTree<int> seg(n);
  rep(i,n) {
    int a;
    cin >> a;
    seg.update(i, a);
  }
  while (q--) {
    int t;
    cin >> t;
    if (t == 1) {
      int x, v;
      cin >> x >> v; x--;
      seg.update(x, v);
    } else if (t == 2) {
      int l, r;
      cin >> l >> r; l--;
      
      cout << seg.query(l, r) << "\n";
    } else {
      int x, v;
      cin >> x >> v; x--;
      /*
      auto ok = [&](int a) {return a >= v;};
      cout << seg.find(x, n, v, ok) + 1 << "\n";
      */
      int l = x, r = n + 1;
      while (r - l > 1) {
        int m = (r + l) / 2;
        if (seg.query(x, m) >= v) r = m;
        else l = m;
      }
      cout << r << "\n";
    }
  }
  return 0; 
}


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

int main() {
  int H,W;
  while (cin >> H >> W, H!=0 || W!=0) {
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if ((i + j) % 2 == 0) {
          cout << "#";
        } else {
          cout << ".";
        }
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3096
#include<stdio.h>
int main(void)
{
	int w,h,n,i,x,y,z=0,a[1001],b[1001];
	scanf("%d %d %d",&w,&h,&n);
	for(i=0;i<n;i++) scanf("%d %d",&a[i],&b[i]);
	for(i=0;i<n-1;i++){
		x=a[i+1]-a[i]; y=b[i+1]-b[i];
		if(x>=0&&y>=0||x<0&&y<0){
			if(x<0){
				x=x*-1; y=y*-1;
			}
			if(x>=y) z+=x;
			else z+=y;
			
		}
		if(x>=0&&y<0||x<0&&y>=0){
			if(x<0) x=x*-1;
			if(y<0) y=y*-1;
			z+=x+y;
		}
	}
	printf("%d\n",z);
	return 0;
}

Measured memory_bytes: 2708
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision


#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

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

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

	//int t; cin >> t;

	//rep(test, t) {
	int h,w, k;
	cin >> h >> w >> k;

	vector<vector<ll>> s(h, vector<ll>(w));
	rep(i,h) { 
	  string _s;
		cin >> _s;
	  rep(j,w) s[i][j] =(ll) _s[j]-'0';
	}

	ll ans = INF;
	rep(_col, 1 << h - 1) {
		bool ok = true;
		vector<int> colline;
		colline.push_back(-1);
		rep(j,h) if (_col >> j & 1) colline.push_back(j);
		colline.push_back(h-1);

		vector<vector<int>> col(colline.size()-1, vector<int>(w,0));
		rep(l, colline.size() - 1) rep(j, w) for (int i = colline[l] + 1; i <= colline[l + 1]; ++i) {
			col[l][j] += s[i][j];
		}

		ll ans0 = colline.size()-2;
		vector<vector<ll>> sum(col.size(), vector<ll>(w, 0));
		rep(j, w) { 
		  bool overk = false;
		  rep(l, col.size()) {
				sum[l][j] += col[l][j];
			  if (j-1 >= 0) sum[l][j] += sum[l][j-1];
				overk = overk || sum[l][j] > k;
			}

			if (overk) { 
			  ans0++;
			  rep(l,col.size()) {
					if (j == 0 || col[l][j] > k) { ok = false; break; }
					sum[l][j] = col[l][j];
				}
				if (!ok) break;
			}
		}

		//debug2D(sum); 

		if (ok) { chmin(ans, ans0); }
		
	}

	cout << ans << endl;
}

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

int main() {
  int D ; 
  cin >> D ; 
  
  if(D == 25){
    cout << "Christmas" << endl ; 
  }
    if(D == 24){
    cout << "Christmas Eve" << endl ; 
  }
    if(D == 23){
    cout << "Christmas Eve Eve" << endl ; 
  }
    if(D == 22){
    cout << "Christmas Eve Eve Eve" << endl ; 
  }
}


Measured memory_bytes: 3604
#include<cstdio>
int main(void){
    int m, d;
    scanf("%d %d", &m, &d);
    int d1, d2;
    int answer=0;
    for(int i=1;i<=m;i++){
        for(int j=1;j<=d;j++){
            d1=j/10, d2=j%10;
            if(d1*d2==i && d1>1 && d2>1){
                answer++;
            }
        }
    }
    printf("%d", answer);
}

Measured memory_bytes: 128
/*
___ is a raging sadist.
*/

//Destroy all WA at test 2

#include <bits/stdc++.h>
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define pb push_back
#define show(x) cout << (#x) << " : " << x << endl;
#define ll long long
#define ld long double
#define pow power
#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll, ll>
#define sq(x) ((x) * (x))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define SZ(a) int((a).size())
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define endl "\n"
#define PI 3.14159265
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll MOD1 = 998244353;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7; 
using namespace std;

ll power(ll x, ll y) 
{ 
   ll res = 1;      
  
   
    while (y > 0) 
    { 
       
        if (y & 1) 
            res = (long long)(res*x); 
  

        y = y>>1; 

        if (x<=100000000)
        x = (long long)(x*x);

        //cout<<x<<'\n'; 
    } 
    return res; 
} 




ll pr[10000001];
ll cnt[10000001];

int main()
{

#ifndef ONLINE_JUDGE    
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif

fastio();

ll N=1e7+1;

  pr[1]=1;
  for (int i=2;i<N;i++){
      if (pr[i]==0){
          for (int j=i;j<N;j+=i){
              pr[j]=i;
          }
      }
  }

cnt[1]=1;

for(int i=2;i<=10000000;i++)
{
    ll num=i;
    ll tcount=1;
    cnt[i]=1;
    ll temp=pr[num];

    while(num!=1)
    {
        num=num/pr[num];
        if (temp==pr[num])
        {
            tcount+=1;
        } else {
            cnt[i]*=(tcount)+1;
            tcount=1;
            temp=pr[num];
        }
    }
}

ll number;
cin>>number; ll fin=0;

for(ll i=1;i<=number;i++)
{
fin+=i*cnt[i];
}

cout<<fin;

return 0;
}

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

int main()
{
    int n;
    long a[200000], diff = 0;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        diff += a[i];
    }

    diff -= 2 * a[0];
    //memo: diff = sumDown - sumUp

    long minDiff = abs(diff);
    for (int i = 1; i < n - 1; ++i) {
        diff -= 2 * a[i];
        if (abs(diff) < minDiff) {
            minDiff = abs(diff);
        }
    }

    cout << minDiff << endl;

    return 0;
}

Measured memory_bytes: 1792
import collections
N=int(input())
v=list(map(int,input().split()))

vo=v[0::2]
ve=v[1::2]

voc=collections.Counter(vo).most_common()
vec=collections.Counter(ve).most_common()

mvo=voc[0][0]
mve=vec[0][0]

if mvo!=mve:
  print(N-voc[0][1]-vec[0][1])
elif len(voc)==1 and len(vec)==1 and mvo==mve:
  print(N//2)
else:
  print(min(N-voc[0][1]-vec[1][1],N-voc[1][1]-vec[0][1]))

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

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

  int a = numbers.at(0) - '0';
  int b = numbers.at(1) - '0';
  int c = numbers.at(2) - '0';
  int d = numbers.at(3) - '0';

  if (a + b + c + d == 7) {
    printf("%d+%d+%d+%d=7", a, b, c, d);
    return 0;
  }
  if (a - b + c + d == 7) {
    printf("%d-%d+%d+%d=7", a, b, c, d);
    return 0;
  }
  if (a + b - c + d == 7) {
    printf("%d+%d-%d+%d=7", a, b, c, d);
    return 0;
  }
  if (a - b - c + d == 7) {
    printf("%d-%d-%d+%d=7", a, b, c, d);
    return 0;
  }
  if (a + b + c - d == 7) {
    printf("%d+%d+%d-%d=7", a, b, c, d);
    return 0;
  }
  if (a - b + c - d == 7) {
    printf("%d-%d+%d-%d=7", a, b, c, d);
    return 0;
  }
  if (a + b - c - d == 7) {
    printf("%d+%d-%d-%d=7", a, b, c, d);
    return 0;
  }
  if (a - b - c - d == 7) {
    printf("%d-%d-%d-%d=7", a, b, c, d);
    return 0;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#define ll long long
using namespace std;

int main(void){
    string s;
    cin >> s;
    for(int i=0;i<s.length();i++){
        if(s[i] == ','){
            cout << " ";
        }else{
            cout << s[i];
        }
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int stnum;
int t[500];
int st[500];
int interv[500];
int main() {
	cin >> stnum;
	for (int i = 0; i < stnum - 1; i++) {
		cin >> t[i] >> st[i] >> interv[i];
	}
	for (int i = 0; i < stnum - 1; i++) {
		int dur = 0;
		for (int j = i; j < stnum - 1; j++) {
			if (dur < st[j]) {
				dur = st[j] + t[j];
			}
			else {
				while ((dur - st[j]) % interv[j] != 0)
					dur++;
				dur += t[j];
			}
		}
		cout << dur << '\n';
	}
	cout << 0 << '\n';

}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int a[150];

int main(){
	int n;
	double sum=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	int avg = round(sum/n);
	//printf("%d\n",avg);
	//printf("5/3=%d\n",5/3);
	long long cost = 0;
	int d;
	for(int i=0;i<n;i++){
		if(a[i]<avg) d=avg-a[i];
		else d=a[i]-avg;
		cost+=d*d;
	}
	printf("%lld\n",cost);
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,m;
int a[12525];

// 何文字, マッチ -> 最後に使った数
int dp[12525][12525];

int use[] = {-1,2,5,5,4,5,6,3,7,6};

int main(){
  scanf("%d%d",&n,&m);
  REP(i,m)scanf("%d",a+i);
  REP(i,n+1)fill(dp[i],dp[i]+12525,-1);
  int keta = 0;
  dp[0][0] = 0;
  REP(i,n+1)REP(j,n)if(dp[i][j]!=-1){
    REP(k,m){
      int d = a[k];
      int u = use[d];
      if(j+u>n)continue;
      if(dp[i+1][j+u] < d){
        dp[i+1][j+u] = d;
        if(j+u==n){
          CHMAX(keta,i+1);
        }
      }
    }
  }
  // DEBUG(keta);
  int curi = keta, curj = n;
  while(dp[curi][curj] != 0){
    int d = dp[curi][curj];
    putchar('0'+d);
    curi--; curj-=use[d];
  }
  puts("");
  return 0;
}


Measured memory_bytes: 489856
n,m = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
ans = 0
counta = []
for i in range(n):
  counta.append(len(a[i])-1)
for i in range(1,m+1):
  counts = 0
  for j in range(n):
    counts += a[j].count(i)  
  counts -= counta.count(i)
  if counts== n:
    ans +=1
  counts=0
print(ans)

Measured memory_bytes: 3064
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>

using namespace std;

vector<int> array_left_rotation(vector<int> a, int n, int k) {
    
}

int main(){
  int N;
  cin >> N;
  vector<int> A(N); 
  for(int i=0;i<N;i++){
    cin >>A[i];
  } 
  int number =0;
  bool frag=1;
  while(frag){
    for(int i=0;i<N;i++){
      if(A[i]%2==0){
	A[i]=A[i]/2;
	if(i==N-1) number +=1;
      } 
      else{
	frag=false;
	break;
      }
    }
  }
  cout << number <<endl;

    return 0;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    n, k = map(int, input().split())
    if n % k == 0:
        print(0)
    else:
        p = [0] * k
        for i in range(n):
            p[i % k] += 1
        print(max(p) - min(p))


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
import sys

s = sys.stdin.readline().split()

a, b = map(int, s)
orig_a = a/0.08
if int(orig_a) < orig_a:
    left = int(orig_a) + 1
else:
    left = int(orig_a)
right = left + 1
while True:
    if int(right * 0.08) > a:
        break
    right += 1
for i in range(left, right):
    if int(i * 0.1) == b:
        print(i)
        sys.exit(0)
print(-1)




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

int n, m;

int solve();

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

  cout << solve() << endl;
  return 0;
}

int solve() {
  int ans = 1;
  for(int i = 1; i <= sqrt(m); ++i) {
    if(m % i == 0) {
      if(m / i >= n) ans = max(i, ans);
      if(i >= n) ans = max(m / i, ans);
    }
  }
  return ans;
}

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

using namespace std;

using ll = long long;

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()

typedef pair<int, int> P;

const int MOD = (int) 1e9 + 7;

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 gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll N, C;
	cin >> N >> C;
	
	vector<ll> x(N + 2), v(N + 2);
	for (ll i = 1; i <= N; i++) {
		cin >> x[i] >> v[i];
	}
	x[0] = 0;
	x[N + 1] = C;
	
	ll cal = 0;
	vector<vector<ll>> dp(2, vector<ll>(100010, 0));
	
	for (ll i = 1; i <= N; i++) {
		cal -= x[i] - x[i - 1];
		cal += v[i];
		dp[0][i] = max(dp[0][i - 1], cal);
		// ここでそれまでのカロリーの最大値をメモ
	}
	
	cal = 0;
	for (ll i = N; i >= 1; i--) {
		cal -= x[i + 1] - x[i];
		cal += v[i];
		dp[1][i] = max(dp[1][i + 1], cal);
	}
	
	ll maxcal = 0;
	for (ll i = 0; i <= N; i++) {
		// 時計回り
		cal = dp[0][i] + dp[1][i + 1] - x[i];
		maxcal = max(maxcal, cal);
		
		// 反時計回り
		cal = dp[0][i] + dp[1][i + 1] - C + x[i + 1];
		maxcal = max(maxcal, cal);
	}
	
	cout << maxcal << endl;
	
	return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>

using namespace std;
typedef long long LL;
static const double EPS = 1e-9;

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

int main(void){  
  int n;
  while(cin>>n,n){
    int maxs;
    int a[5001] = {0};
    REP(i,n) cin >> a[i];
    maxs = a[0];
    FOR(i,0,n){
      int sum =0;
      FOR(j,i,n){
        sum += a[j];
        maxs = max(sum, maxs);
      }
    }
    cout << maxs << endl;
  }
  return 0;
}

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

r,l=0,0
ans=0
sum_a=0

while r<n:
    if sum_a+a[r]==(sum_a^a[r]):
        sum_a+=a[r]
        r+=1
        ans+=r-l
    elif l==r:
        l+=1
        r+=1
    else:
        sum_a-=a[l]
        l+=1
print(ans)

Measured memory_bytes: 24712
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#define Mod 1000000007
using namespace std;
int f[51][51];
int C[51][51];
void add(int& x,int y)
{
	x+=y;
	if(x>=Mod)x-=Mod;
	return ;
}
int main()
{
	int n;
	scanf("%d",&n);
	C[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		C[i][0]=1;
		for(int j=1;j<=i;j++)
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%Mod;
	}
	f[1][0]=f[1][1]=n;
	for(int i=1;i<n;i++)
		for(int j=0;j<=i;j++)
			for(int x=max(1,j);i+x<=n;x++)
			{
				if((j+x)&1)continue;
				int num=(j+x)/2;
				for(int y=0;y<=x;y++)
					add(f[i+x][abs(num-y)],(long long)f[i][j]*C[n-i][x]%Mod*C[x][y]%Mod);
			}
	printf("%d\n",f[n][0]);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        int sum = 0;
        while (scanner.hasNextInt()) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            System.out.println(getDigit(a + b));
        }
    }

    static int getDigit(int value) {
        if (value == 0) { return 1; }

        int digit = 0;

        while (value > 0) {
            value /= 10;
            digit++;
        }

        return digit;
    }

}

Measured memory_bytes: 26664
#include <iostream>
#include <algorithm>

#define rep(i, n) for(int i = 0; i < n; ++i)

using namespace std;

int n;
char s[100001];
int x[100000];

int next(int i){
  int p = x[i ? i - 1 : n - 1];
  return (s[i] == 'o') ^ x[i] ? p : !p;
}

int main(){
  cin >> n >> s;
  rep(i, 2){
    x[0] = i;
    rep(j, 2){
      x[1] = j;
      for(int k = 1; k + 1 < n; ++k){
        x[k + 1] = next(k);
      }
      if(next(n - 1) == i && next(0) == j){
        rep(l, n){
          cout << (x[l] ? 'W' : 'S');
        }
        cout << endl;
        return 0;
      }
    }
  }
  cout << -1 << endl;
  return 0;
}

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

typedef long long ll;

double A, B, X;

int main() {
  cin >> A >> B >> X;
  cout << setprecision(10);
  if (X >= A * A * B / 2) {
    cout << atan(((A * A * B - X) * 2 / A / A) / A) / M_PI * 180 << endl;
  } else {
    cout << atan(B / (X * 2 / A / B)) / M_PI * 180 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
N, M, C = map(int, input().split())
B = list(int(x) for x in input().split())

z = 0
for i in range(N):
    A = list(int(x) for x in input().split())
    ab = 0
    for j in range(M):
        ab += A[j] * B[j]
    if (ab + C) > 0:
        z += 1
print(z)

Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>

struct LENGTH
{
	int length1;
	int length2;
	int length3;
};

int main()
{
	struct LENGTH length[1000];
	int count,set,change;

	scanf("%d",&set);

	for(count = 0;count<set;count++)
	{
		scanf("%d %d %d", &length[count].length1, &length[count].length2, &length[count].length3);

		if(length[count].length1<length[count].length3)
		{
			change = length[count].length1;
			length[count].length1 = length[count].length3;
			length[count].length3 = change;
		}
		if(length[count].length1<length[count].length2)
		{
			change = length[count].length1;
			length[count].length1 = length[count].length2;
			length[count].length2 = change;
		}
		if(length[count].length2<length[count].length3)
		{
			change = length[count].length2;
			length[count].length2 = length[count].length3;
			length[count].length3 = change;
		}
	}

	for(count=0;count<set;count++)
	{
		if((length[count].length1 * length[count].length1) == ((length[count].length2 * length[count].length2) + (length[count].length3 * length[count].length3)))
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 588
#include<bits/stdc++.h>
#define ll long long int
#define vi vector<ll>
#define vii vector<vector<int>>
#define mii map<int,int>
#define pb push_back
#define mod 1e9 + 7;
const int INF = 1e9 + 5;
#define PQ priority_queue<int>
#define pii pair<int, int>
#define ff first
#define ss second
#define endl "\n"

using namespace std;

int main(){

	int n, k;
	cin>>n>>k;
	vi h(n), dp(n, INT_MAX);
	dp[0]=0;
	for(int i=0; i<n; i++)cin>>h[i];

	for(int i=0; i<n; i++){
		
		for(int j=i+1; j<=i+k; j++){
			if(j<n){
				dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
			}
		}
	}

	cout<<dp[n-1]<<endl;

}

Measured memory_bytes: 4844
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!
 
/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define l long
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<int,int>
#define maxn 1000000000005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;
 
signed main()
{
    fast;
    char c;
    cin>>c;
    c = c + 1;
    cout<<c;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def binbin(binn):
    return bin(binn).count("1")


def popcount(n):
    if n == 0:
        return 0
    return 1 + popcount(n % binbin(n))


def main():
    N = int(input())
    X = input().strip()

    x1 = 0
    xc = binbin(int(X, 2))
    if xc == 1:
        x2 = -1
    else:
        x2 = 0
    for i in range(N):
        if X[-1 - i] == '1':
            x1 += pow(2, i, xc + 1)
            if x2 != -1:
                x2 += pow(2, i, xc - 1)
    for i in range(N):
        if X[i] == '0':
            print(1 + popcount((x1 + pow(2, N - i - 1, xc + 1)) % (xc + 1)))
        else:
            if x2 == -1:
                print(0)
            else:
                print(1 + popcount((x2 - pow(2, N - i - 1, xc - 1) + xc - 1) % (xc - 1)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9556
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
double dp[16][3][3];
char s,t,b;
int main() {
    int n, sx, sy, tx, ty, bx, by;
    while (scanf("%d",&n)) {
        if (!n) break;
        memset(dp, 0, sizeof(dp));
        cin>>s>>t>>b;
        sx=(s-'A')/3; sy=(s-'A')%3;
        tx=(t-'A')/3; ty=(t-'A')%3;
        bx=(b-'A')/3; by=(b-'A')%3;
        dp[0][sx][sy]=1.0;
        for (int i=0; i<=n; i++) {
            for (int j=0; j<3; j++) {
                for (int k=0; k<3; k++) {
                    for (int l=0; l<4; l++) {
                        int x=j+dx[l], y=k+dy[l];
                        if (x>=0&&x<3&&y>=0&&y<3&&(x!=bx||y!=by)) {
                            dp[i+1][x][y]+=dp[i][j][k]/4.0;
                        } else {
                            dp[i+1][j][k]+=dp[i][j][k]/4.0;
                        }
                    }
                    // printf("%f%c",dp[i][j][k],k==2?'\n':' ');
                }
            }
        }
        printf("%.8f\n",dp[n][tx][ty]);
    }
}

Measured memory_bytes: 0
import fractions

A, B, C, D = [int(x) for x in input().split()]

X = (C * D) // fractions.gcd(C, D)
ans = (B - A + 1)\
      - (B // C - A // C)\
      - (B // D - A // D)\
      + (B // X - A // X)
if A % C == 0:
      ans -= 1
if A % D == 0:
      ans -= 1
if A % X == 0:
      ans += 1

print(ans)


Measured memory_bytes: 5048
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main()
{
    long long n,r1,r2;
    cin>>n;
    r1=sqrt(n);
    while(n%r1!=0)
    {
        r1-=1;
    }
    r2=n/r1;
    cout<<r1+r2-2<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
S = [int(x) - ord('A') for x in read().rstrip()]

S = [(x + N) % 26 for x in S]

answer = ''.join(chr(x + ord('A')) for x in S)
print(answer)

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void compress(vector<ll> &v){
    ll N = v.size(), mn = LINF;
    vector<pair<ll,int>> a(N);
    for(int i=0; i<N; ++i){
        a[i].first = v[i];
        a[i].second = i;
        mn = min(mn, v[i]);
    }
    sort(a.begin(), a.end());
    
    int prev = mn-1, n = -1;
    for(int i=0; i<N; ++i){
        if(a[i].first == prev) v[a[i].second] = n;
        else{
            n++;
            prev = a[i].first;
            v[a[i].second] = n;
        }
    }
}

void Main(){
    ll N,A,B; cin >> N >> A >> B;

    if(!(A+B<=N+1 && A*B>=N)){
        cout << -1 << en;
        return;
    }

    auto f = [&](ll i, ll j){return i*A+j;};
    VL ans; REP(i,B) ans.push_back(f(B-1-i,0));
    N -= B;

    if(A>1){
        REP(i,N%(A-1)){
            REP(j,(N+A-2)/(A-1)) ans.push_back(f(B-1-j,i+1));
        }

        FOR(i,N%(A-1),A-1){
            REP(j,N/(A-1)) ans.push_back(f(B-1-j,i+1));
        }
    }

    N += B;
    compress(ans);
    REP(i,N) cout << ans[i]+1 << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

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

int main(){
  int n, a, b;
  cin >> n >> a >> b;
  int total = 0;
  for(int i = 1; i <= n; i++){
    int sum = 0, temp = i;
    while(temp > 0){
      sum += temp % 10;
      temp /= 10;
    }
    if(sum >= a && sum <= b){
      total += i;
    }
  }
  cout << total << endl;
  return 0;
}

Measured memory_bytes: 3628
import java.util.*;

class Main{
    static boolean dp[] = new boolean[(int)1e5+10];
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        char[] s = in.next().toCharArray();
        dp[0] = true;
        for(int i = 0 ; i < s.length; i++){
            if(!dp[i])continue;
            if(i+5<=s.length&&s[i]=='d'&&s[i+1]=='r'&&s[i+2]=='e'&&s[i+3]=='a'&&s[i+4]=='m')
                dp[i+5] = true;
            if(i+7<=s.length&&s[i]=='d'&&s[i+1]=='r'&&s[i+2]=='e'&&s[i+3]=='a'&&s[i+4]=='m'&&s[i+5]=='e'&&s[i+6]=='r')
                dp[i+7] = true;
            if(i+5<=s.length&&s[i]=='e'&&s[i+1]=='r'&&s[i+2]=='a'&&s[i+3]=='s'&&s[i+4]=='e')
                dp[i+5] = true;
            if(i+6<=s.length&&s[i]=='e'&&s[i+1]=='r'&&s[i+2]=='a'&&s[i+3]=='s'&&s[i+4]=='e'&&s[i+5]=='r')
                dp[i+6] = true;
        }

        if(dp[s.length])
            System.out.println("YES");
        else System.out.println("NO");
    }
}

Measured memory_bytes: 27632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] p = new int[n];

        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
        }

        double[] tmp = new double[n];
        for (int i = 0; i < n; i++) {
            tmp[i] = (p[i]-1) / 2.0 + 1;
        }

        double max = 0;
        for (int i = 0; i < k; i++) {
            max += tmp[i];
        }

        int j = 0;
        double t = max;
        for (int i = k; i < n; i++) {
            t = t - tmp[j++] + tmp[i];
            max = Math.max(t, max);
        }

        System.out.println(max);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

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

int main() {
  int N;
  cin >> N;
  int H[N],dp[N];
  for(int i=0;i<N;i++) cin >> H[i];
  
  dp[0]=0;
  dp[1]=abs(H[0]-H[1]);
  for(int i=2;i<N;i++){
    dp[i] = min(dp[i-1]+abs(H[i]-H[i-1]) , dp[i-2]+abs(H[i]-H[i-2]));
  }
  
  cout << dp[N-1] << endl;
  return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, ans = 0;
  bool flag = false;
  cin >> n;
  vector<int> vec(n);
  for (int i = 1; i <= n; i++) {
    cin >> vec[i];
  }

  for (int i = 1; i <= n; i++) {
    if (vec[i] == i) {
      i++;
      ans++;
    }
  }

  cout << ans << '\n';
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
    long long  Gcd(long long a,long long b);
    long long  Lcm(long long a,long long b);
    long long a,b;
    long long gcd,lcm;
    while(cin>>a>>b)
    {
        gcd=Gcd(a,b);
        lcm=Lcm(a,b);
        cout<<gcd<<" "<<lcm<<endl;
    }
    return 0;
}
long long Gcd(long long a,long long b)
{
    return b==0?a:Gcd(b,a%b);
}
long long Lcm(long long a,long long b)
{
    return (a*b)/(Gcd(a,b));
}



Measured memory_bytes: 2984
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pl = pair<ll, ll>;
const ll INF = ll(1e18);
const ll mod = ll(1e9 + 7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rnfor(i,a,b) for(ll (i) = (b) - 1; (i) >= (a); --(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
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; }
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

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

vector<ll> FactorialInv, Factorial;

void init_combination(ll MAX){
    Factorial.resize(MAX + 1);
    FactorialInv.resize(MAX + 1);
    Factorial[0] = 1;
    for(int i = 1; i <= MAX; i++){
        Factorial[i] = Factorial[i - 1] * i % mod;
    }
    FactorialInv[MAX] = power(Factorial[MAX], mod - 2);
    for(ll i = MAX - 1; i >= 0; i--) {
        FactorialInv[i] = FactorialInv[i+1] * (i+1) % mod;
    }
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    if(b < 0) return 0;
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}


//modの値の確認をすること
int main(){
    ll a;
    cin >> a;
    pf(a + a * a + a * a * a);
    return 0;
}


Measured memory_bytes: 3632
a_number = gets.to_i
p_array = gets.strip.split.map(&:to_i)
q_array = gets.strip.split.map(&:to_i)


perm = Array(1..a_number).permutation.to_a
p_n = 0
q_n = 0
n = 1
perm.each do |p|
  if p == p_array
    p_n += n
  end
   if p == q_array
    q_n += n
  end
  n+=1
end
puts (p_n - q_n).abs
  



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

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

	string s; cin >> s;
	int N = s.length();
	for (int i = 0; i < N-1; i++) {
		if (s[i] == 'C') {
			for (int j = i + 1; j < N; j++) {
				if (s[j] == 'F') {
					cout << "Yes";
					return 0;
				}
				if (j == N - 1) {
					cout << "No";
					return 0;
				}
			}
		}
	}
	cout << "No";
}


Measured memory_bytes: 256
import sys
n=1001
a=range(1,n)
a+=[n]+a[::-1]

for n in map(int,sys.stdin):
  x=0
  b,c=0,n
  if n>2000: b,c=n-2000,2000
  for i in range(b,c+1):
    x+=a[i]*a[n-i]
  print x

Measured memory_bytes: 4312
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl                endl

using namespace std;
const int MOD   = (int)(1e9 + 7);
const int INF   = (int)(1e13 + 7);
const double PI = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int pow(int x, int y) {                                                             //return x^y in order(log(y))
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

class DPreparingBoxes {
public:
  static void solve(istream &cin, ostream &cout) {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    vector<int> ball(N, 0);
    for (int i = N - 1; i >= 0; i--) {
      int now = 0;
      for (int j = i; j < N; j += (i + 1)) {
        now += ball[j];
      }
      if (now % 2 != a[i]) {
        ball[i] = 1;
      }
    }
    cout << accumulate(ALL(ball), 0LL) << endl;
    rep(i, N) {
      if (ball[i]) {
        cout << i + 1;
        if (i != N - 1) {
          cout << " ";
        }
      }
    }
    if (accumulate(ALL(ball), 0LL) > 0)
      cout << endl;
  }
};


signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  DPreparingBoxes solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 3968
import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N, M = map(int, rl().split())
    
    counter = defaultdict(int)
    for _ in range(M):
        a, b = map(int, rl().split())
        counter[a] += 1
        counter[b] += 1
    
    for i in range(1, N + 1):
        if counter[i] % 2:
            print('NO')
            return
    print('YES')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 15436
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
long long a[10000000];
inline int read(){
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}

void bfs(){
  queue<long long>QUE;
  QUE.push(0);
  int k=9;
  int f=1;
  while(!QUE.empty()){
  	  long long x=QUE.front();
  	  QUE.pop();
  	    a[f]=x;
    	f++;
    	if(f==170)
    	break;
    	long long k=x*10+0;
		if(k!=0)
		QUE.push(k);
		QUE.push(k+1); 
      
  }
} 
int main(){
   long long n;
   cin>>n;
   cout<<(1+n-1)*(n-1)/2<<endl;
    
 	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
ll m=1000000007;
ll sieve[1000001]={0},i,j;
ll power(ll p, ll k)
{
ll a=1;
while(k)
{
if(k&1)
a=(a*p)%m;
p=(p*p)%m;
k>>=1;
}
return a;
}
using namespace std;
int main()
{
 
 int tc=1;
// cin>>tc;
 while(tc--)
 {
ll n,m;
cin>>n>>m;
ll ans=0;
if(n>=1)
ans+=n*(n-1)/2;
if(m>=1);
ans+=m*(m-1)/2;
cout<<(ans);
	 cout<<"\n";
 }
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 500000
#define BIG 1000000000

void merge(int *,int,int,int);
void mergeSort(int *,int,int);

int count=0;
int main(){
 
int n,i;
int A[MAX];

scanf("%d",&n);
for(i=0;i<n;i++) scanf("%d",&A[i]);

mergeSort(A,0,n); 

for(i=0;i<n-1;i++) printf("%d ",A[i]);
printf("%d\n",A[n-1]);
printf("%d\n",count);

return 0;


}

void merge(int *A,int left,int mid,int right){
int n1,n2,i,j,k;
  n1=mid-left;
  n2=right-mid;
  int L[n1+1];
  int R[n2+1];
  
  for(i=0;i<=n1-1;i++){
    L[i]=A[left+i];
  }
  for(j=0;j<=n2-1;j++){
    R[j]=A[mid+j];
  }
  L[n1]=BIG;
  R[n2]=BIG;
  i=0;
  j=0;
  for(k=left;k<=right-1;k++){
   if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
      count++;
    }
    else{
      A[k]=R[j];
      j++;
      count++;
    }
  }
}


void mergeSort(int *A,int left,int right){

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



Measured memory_bytes: 5644
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
using namespace std;
int main()
{
    char str1[5];
    char str2[5];
   // gets(str1);
    //gets(str2);
    for(int i=0;i<3;i++)
        scanf("%c",&str1[i]);
    getchar();
    for(int j=0;j<3;j++)
        scanf("%c",&str2[j]);
    int i;
    for(i=0;i<3;i++)
    {
        if(str1[i]!=str2[2-i])
            break;
    }
    getchar();
    if(i==3)
        printf("YES\n");
    else printf("NO\n");
    return 0;
}


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

typedef long long ll;

int main(int argc, char* argv[])
{
  ll N;
  std::cin >> N;

  std::map<ll, ll> sum_cnt;

  ll sum = 0;
  sum_cnt[0] = 1;

  for (ll i = 0; i < N; i++) {
    ll A;
    std::cin >> A;
    sum += A;
    sum_cnt[sum]++;
  }

  ll ans = 0;
  for (std::map<ll,ll>::iterator it = sum_cnt.begin(); it != sum_cnt.end(); it++) {
    ll num = it->second;

    if (num > 1) {
      ans += num * (num - 1) / 2;
    }
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 12800