akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
//define
#define int long long
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define Rep(x,y) for(int k=x;k<y;k++)
#define str string
#define vint vector<int>
#define vvint vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vool vector<bool>
#define vtr vector<str>
#define vvtr vector<vector<str>>
#define qint queue<int>
//pairdefine
#define pint pair<int,int>
#define pic pair<int,char>
#define pci pair<char,int>
#define pis pair<int,str>
#define psi pair<str,int>
#define pcc pair<char,char>
#define pss pair<str,str>
#define mp make_pair
//mapdefine
#define mint map<int,int>
#define mic map<int,char>
#define mci map<char,int>
#define mis map<int,str>
#define msi map<str,int>
#define pb() push_back()
#define all(x) x.begin(),x.end()
#define elif else if
//function
int W=30;
str Dir;
bool shizuku(double Dir);
//UnionFind
struct UnionFind{
  vint par;
  UnionFind(int N):par(N){
    rep(0,N)par[i]=i;
  }
  int root(int x){
    if(par[x]==x)return x;
    return par[x]=root(par[x]);
  }
  void unite(int x,int y){
    int rx=root(x);
    int ry=root(y);
    if(rx==ry)return;
    par[rx]=ry;
  }
  bool same(int x,int y){
    return root(x)==root(y);
  }
};

signed main(){
    int pow,N,M,X,count=0,count2=0,Deg;
    double Dis;
    int C='A'-'a';
    char op;
    str S,T;
    cin>>S;
    rep(0,S.size()){
      if(S.at(i)=='x')count+=1;
    }
    if(count>=8){
      cout<<"NO"<<endl;
    }
    else cout<<"YES"<<endl;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n; std::cin >> n;
  map<int, int> cnt;
  rep(i, n) {
    int a; std::cin >> a;
    cnt[a]++;
  }
  int ans = 0;
  for (auto &p : cnt) {
    if (p.fi > p.se) ans += p.se;
    else ans += p.se - p.fi;
  }
  std::cout << ans << "\n";
}


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

#define PI 4*atan(1)
#define INF 1e8

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  int min = INF, max = -100;
  for(int i = 0; i < N; i++){
    cin >> a[i];
    if(min > a[i])min = a[i];
    if(max < a[i])max = a[i];
  }

  int answer = INF;
  for(int i = min; i <= max; i++){
    int sum = 0;
    for(int j = 0; j < N; j++){
      sum += pow(i - a[j], 2);
    }
    if(answer > sum)answer = sum;
  }
  cout << answer << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

bool comp(const string& i, const string& j){
	return (i > j);
}
int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	lli a, b;
	cin >> a >> b;
	if((a*b)%2 == 0) cout << "Even" << endl;
	else cout<< "Odd" << endl;
	return 0;
}

Measured memory_bytes: 256
function parseInt(x) parse(Int, x) end
function conInt(x) convert(Int, x) end

function main()
	n = parseInt(readline())
	x = Int[]
	sum = 0
	for i in 1:n
		push!(x, parseInt(readline()))
	end
	y = sort(x)
	if length(x) == 2
		println(y[2]-y[1])
	else
		sum += y[n]-y[1]
		if n%2 == 1
			for i in 1:conInt((n-3)/2)
				sum += y[n-i]-y[i]
				sum += y[n+1-i]-y[i+1]
			end
			sum += max(y[conInt((n+1)/2)]-y[conInt((n-1)/2)], y[conInt((n+3)/2)]-y[conInt((n+1)/2)])
		else
			for i in 1:conInt((n-4)/2)
				sum += y[n-i]-y[i]
				sum += y[n+1-i]-y[i+1]
			end
			sum += max(y[conInt(n/2)]-y[conInt((n-2)/2)]+y[conInt((n+4)/2)]-y[conInt((n+2)/2)], y[conInt((n+2)/2)]-y[conInt((n-2)/2)]+y[conInt((n+4)/2)]-y[conInt(n/2)])
		end
		println(sum)
	end
end
main()

Measured memory_bytes: 188580
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        String s = stdIn.next();
        String t = stdIn.next();
        int count = 0;
        for(int i = 0;i<s.length();i++) {
            if(s.charAt(i) == t.charAt(i)) {
                count++;
            }
        }
        System.out.println(count);
        }
}

Measured memory_bytes: 21844
package main

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

func main() {
	readVariables()
	ans := -1
	dist := AbsInt(X - ans)
	for i := -1; i < 200; i++ {
		if exclude[i] {
			continue
		}
		if AbsInt(X-i) < dist {
			dist = AbsInt(X - i)
			ans = i
		}
	}
	fmt.Println(ans)
}

var (
	X, N    int
	exclude map[int]bool = make(map[int]bool)
)

func readVariables() {
	X, N = nextInt(), nextInt()
	for i := 0; i < N; i++ {
		exclude[nextInt()] = true
	}
}

/* Template */

var scanner *bufio.Scanner

func init() {
	Max := 1001001
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 0, Max), Max)
	scanner.Split(bufio.ScanWords)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}

// MinInt returns minimum argument
func MinInt(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

//MaxInt returns maximum argument
func MaxInt(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

//AbsInt returns |x| for x
func AbsInt(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

//ModPow calculates integer power with modulo operation
//if modulo <= 1, it powers w/o module operation
//if base < 0, return value might be negative too.
func ModPow(base, exponent, modulo int) (result int) {
	result = 1
	for exponent > 0 {
		if exponent%2 == 1 {
			result *= base
			if modulo > 1 {
				result %= modulo
			}
		}
		base *= base
		if modulo > 1 {
			base %= modulo
		}
		exponent /= 2
	}
	return
}

//Gcd
func Gcd(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = gcd(result, vals[i])
	}
	return
}

func gcd(x, y int) int {
	x, y = AbsInt(x), AbsInt(y)
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

//Lcm
func Lcm(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = lcm(result, vals[i])
	}
	return
}

func lcm(x, y int) int {
	return x * y / gcd(x, y)
}


Measured memory_bytes: 1840
// Remeber Choose Compiler: GCC9
#include <bits/stdc++.h>

using namespace std;

// Debug Output Utility
#ifdef LOCAL
#define dbg(args...)             \
    do {                         \
        cout << #args << " -> "; \
        err(args);               \
    } while (0)
void err() { std::cout << std::endl; }
template <typename T, typename... Args>
void err(T a, Args... args) {
    std::cout << a << ' ';
    err(args...);
}
template <template <typename...> class T, typename t, typename... A>
void err(const T<t> &arg, const A &... args) {
    for (auto &v : arg)
        std::cout << v << ' ';
    err(args...);
}
#else
#define dbg(...)
#endif

// Macro Definitions:
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

// Type Alias:
using int64 = long long;
using PII   = pair<int, int>;

// Global Const Variable
const int64 INF = 0x3f3f3f3f3f3f3f3f;
const int MOD   = 1000000007;
const int MAXN  = 1005;
const int M     = 1000005;

map<int64, int64> m;

void run() {
    int n;
    int64 x, sum = 0;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> x, sum += x, m[x]++;
    int q;
    int64 b, c;
    cin >> q;
    while (q--) {
        cin >> b >> c;
        if (m.count(b)) {
            sum += (c - b) * m[b];
            m[c] += m[b];
            m.erase(b);
        }
        cout << sum << endl;
    }
}

// Debug Input Redirection
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
#endif
    run();
}


Measured memory_bytes: 7608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
double a[102];
double sum;
int main()
{
    int n,m;  cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        scanf("%lf",&a[i]);
        sum+=a[i];
    }
    sort(a+1,a+n+1,greater<int>());
    if(a[m]>=sum/4.0/m)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    return 0;
}



Measured memory_bytes: 256
N,M=map(int, input().split())
D=[]
E=[]
if M%2==0:
  if N%2==0:
    N-=1
  a=(N+1)//2
  for i in range(a//2):
    D.append((i+1,a-i))
  for d,e in D:
    E.append((d+a,e+a-1))
else:
  if N%2==0:
    N-=1
  a=N//2
  for i in range(a//2):
    D.append((i+1,a-i))
  for d,e in D:
    E.append((d+a+1,e+a))
  E.append((a+1,N))
F=D+E
for i in range(M):
  print(*F[i])

Measured memory_bytes: 21836
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}

ll f(ll n){
  return n%4==0 ? n:n^f(n-1);
}

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

  if(a>0) a--;
  cout<<(f(a)^f(b))<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 505
using namespace std;
int k,a[N][N];
int main(){
    scanf("%d",&k);
    if(k==1){puts("1\n1");return 0;}
    int n=(k+3)/4*2;
    for(int i=0;i<n;++i)
        for(int j=0;j<n;++j)
            if(i&1)a[i][j]=n+(i+j)%n+1;
            else a[i][j]=(i+j)%n+1;
    for(int i=0;i<n;++i)
        for(int j=0;j<n;++j)
            if(a[i][j]>k)a[i][j]-=n;
    printf("%d\n",n);
    for(int i=0;i<n;++i)
        for(int j=0;j<n;++j)printf("%d%c",a[i][j]," \n"[j==n-1]);
}


Measured memory_bytes: 2176
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
#include<cmath>
#include<cstring>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    int i=0;
    int coin = 0;
    while(coin<C){
        ++i;
        if(i%7==0)coin+=B;
        coin+=A;
    }
    cout << i << endl;
    return 0;
}


Measured memory_bytes: 3116
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

// strongly connected component
struct scc {
  using Graph = std::vector<std::vector<int>>;
  Graph G, rG;
  std::vector<int> vs, cmp;
  std::vector<bool> used;

  explicit scc(int N): G(N), rG(N) {}

  void dfs(int v) {
    used[v] = true;
    for(auto c: G[v]) if(!used[c]) dfs(c);
    vs.push_back(v);
  }
  void rdfs(int v, int k) {
    used[v] = true;
    cmp[v] = k;
    for(auto c: rG[v]) if(!used[c]) rdfs(c, k);
  }
  int build() {
    int V = G.size();
    used.assign(V, false);
    vs.clear();
    vs.reserve(V);
    cmp.resize(V);
    for(int v = 0; v < V; ++v) if(!used[v]) dfs(v);
    std::fill_n(used.begin(), V, false);
    int k = 0;
    for(int i = vs.size()-1; i >= 0; --i) {
      if(!used[vs[i]]) rdfs(vs[i], k++);
    }
    return k;
  }
  void add_edge(int fr, int to) {
    G[fr].push_back(to); rG[to].push_back(fr);
  }
};

// zarray
void zarray(std::string s, std::vector<int>& Z) {
  int N = s.size(), L, R = 0;
  Z.resize(N);
  for(int i = 1; i < N; ++i) {
    if(i > R) {
      L = R = i;
      while(R < N && s[R-L]==s[R]) ++R;
      Z[i] = R-- -L;
    } else if(Z[i-L] < R-i+1) {
      Z[i] = Z[i-L];
    } else {
      L = i;
      while(R < N && s[R-L] == s[R]) ++R;
      Z[i] = R-- -L;
    }
  }
}

int main() {
  std::string S, T; std::cin >> S >> T;
  int N = S.size(), M = T.size(), K = N+M-1;
  std::string U = S;
  for(int i = 0; i < (M-1)/N; ++i) U += S;
  U += S.substr(0, K - U.size());
  std::vector<int> Z;
  zarray(T+" "+U, Z);
  std::vector<int> v;
  for(int i = 0; i < N; ++i) if(Z[M+1+i]>=M) v.push_back(i);

  scc sc(N);
  if(v.size() < 1) fin(0);
  for(int fr: v) {
    int to = (fr+M)%N;
    if(fr == to) fin(-1);
    sc.add_edge(fr, to);
  }
  if(sc.build() < N) fin(-1);

  std::vector<int> depth(N, -1);
  int ans = 0;
  auto calc_depth = [&](auto&& f, int v) {
    if(depth[v] >= 0) return depth[v];
    int res = -1;
    for(auto c: sc.G[v]) res = std::max(res, f(f, c));
    ++res;
    return depth[v] = res;
  };
  for(int i = 0; i < N; ++i) {
    ans = std::max(ans, calc_depth(calc_depth, i));
  }
  fin(ans);

  return 0;
}


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

int main() {
	array<int, 3> a;
	cin >> a[0] >> a[1] >> a[2];
	int max = a[0];
	int index = 0;
	for (int i = 1; i < 3; i++) {
		if (max < a[i]) {
			max = a[i];
			index = i;
		}
	}
	int temp = 0;

	for (int i = 0; i < 3; i++) {
		if (i != index) temp += a[i];
	}

	cout << max * 10 + temp << endl;
}

Measured memory_bytes: 256
using System;

namespace atcoderA
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);
            if (A == 1)
            {
                A = 14;
            }
            if (B == 1)
            {
                B = 14;
            }

            var ans = "";
            if (A > B)
            {
                ans = "Alice";
            }
            else if (B > A)
            {
                ans = "Bob";
            }
            else
            {
                ans = "Draw";
            }
            Console.WriteLine(ans);
        }
    }
}

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

signed main(){
	int n,x;
	while(cin >> n >> x and !(n==0 and x==0)){
		int cnt = 0;
		for(int i=1;i<=n;i++){
			for(int j=i+1;j<=n;j++){
				for(int k=j+1;k<=n;k++){
					if(i+j+k == x) cnt++;
				}
			}
		}
		cout << cnt << endl;
	}
}


Measured memory_bytes: 3032
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { reader: s.lock() };
    let s = sc.chars();
    let n = s.len();
    let mut ans = 0;
    let mut white = 0;
    for i in 0..n {
        if s[i] == 'W' {
            assert!(i >= white);
            ans += i - white;
            white += 1;
        }
    }
    println!("{}", ans);
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
n = gets.chomp.to_i
t,a = gets.chomp.split.map(&:to_i)
h = gets.chomp.split.map(&:to_i)

result = h.map do |i|
    (a - (t - (i * 0.006))).abs
end

puts (result.index(result.min) + 1)

Measured memory_bytes: 2044
#include <iostream>
#include <queue>
#include <stdio.h>
#include <vector>

#define MAX_N 100'000

using namespace std;

typedef long long ll;

int main() {
  int N, M;
  cin >> N >> M;
  priority_queue<int, vector<int>, less<vector<int>::value_type>> A;
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    A.push(a);
  }

  for (int i = 0; i < M; ++i) {
    int a = A.top();
    A.pop();
    a = a / 2;
    A.push(a);
  }

  ll ans = 0;
  while (!A.empty()) {
    ll a = A.top();
    A.pop();
    ans += a;
  }
  printf("%lld\n", ans);
}

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

using namespace std;

const int CountOfMonth[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

int calculationDaysOfYear(int y, int m, int d) {
	int cnt = 0;

	for (int i = 1; i < m; i++) {
		cnt += CountOfMonth[i];
	}
	cnt += d;
	if (m > 2) {
		if (y % 4 == 0 && y % 100 != 0 || y % 400 == 0) {
			cnt++;
		}
	}
	
	return cnt;
}

int main() {
	int y1, m1, d1, y2, m2, d2,cntDays;
	int countDaysOfYear[2];

	while (cin >> y1 >> m1 >> d1 >> y2>> m2 >> d2, y1 > 0) {
		countDaysOfYear[0] = calculationDaysOfYear(y1, m1, d1);
		countDaysOfYear[1] = calculationDaysOfYear(y2, m2, d2);
		cntDays = countDaysOfYear[1] - countDaysOfYear[0];
		//cout << countDaysOfYear[0] << endl << countDaysOfYear[1] << endl;
		
		for (int i = y1; i < y2; i++) {
			cntDays += 365;
			if (i % 4 == 0 && i % 100 != 0 || i % 400 == 0) {
				cntDays++;
			}
		}
		cout << cntDays << endl;
	}

	return 0;
}


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

long long H, W;

int main() {
  ios_base::sync_with_stdio(0);
  cin >> H >> W;
  if(H == 1 || W == 1) cout << "1\n";
  else cout << ((H * W) - 1) / 2 + 1 << "\n";
}


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

const int MAXN=1e5+10;
vector<int> v[MAXN];
int h[MAXN];

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n,m,f=1,ans=0;
    cin>>n>>m;
    
    for(int i=1;i<=n;i++)
        cin>>h[i];
    
    for(int i=1;i<=m;i++){
        int a,b;
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    
    for(int i=1;i<=n;i++){
        f=1;
        for(vector<int>::iterator it=v[i].begin();it!=v[i].end();it++)
            if(!(h[i]>h[*it]))
                f=0;
        if(f==1)
            ans++;        
    }
    
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 10260
import java.io.*;
import java.util.*;
public class Main
{
    public static void main(String[] args) throws IOException{
    int sub1 = 0;
    int sub2 = 0;
    int sub3 = 0;
    int i = 1;
    String s;
    int a = 0;
    int b = 0;
    int c = 0;
    int cn = 0;
        while(i>0){
            BufferedReader x = new BufferedReader(new InputStreamReader(System.in));
            s = x.readLine();
            StringTokenizer st = new StringTokenizer(s," ");
            a = Integer.parseInt(st.nextToken());
            b = Integer.parseInt(st.nextToken());
            c = Integer.parseInt(st.nextToken());
            if(a >= -1000 && a <= 1000 )
                i = -1;
            else if(b >= -1000 && b <= 1000)
                i = -1;
            else if(c >= -1000 && c <= 1000)
                i = -1;
            else
                i = 1;
         }
        sub1 = b-c;
            if(sub1>0){
            cn = b;
            b = c;
            c = cn;
            sub2 = a-b;
                if(sub2>0){
                cn = a;
                a = b;
                b = cn;
                sub3 = b-c;
                    if(sub3>0){
                    cn = b;
                    b = c;
                    c = cn;
                    }
                }
            }
            else{
            sub2 = a-b;
                if(sub2>0){
                cn = a;
                a = b;
                b = cn;
                sub3 = b-c;
                    if(sub3>0){
                    cn = b;
                    b = c;
                    c = cn;
                    }
                }
            }            
    System.out.println(""+a+" "+b+" "+c+"");
    }
}

Measured memory_bytes: 24252
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <iomanip>
#include <sstream>
using namespace std;

int sum_digit(int n){
  if( n == 0 ) return 0;
  else return n%10 + sum_digit(n/10);
}

int main()
{
  int i,N,L; cin >> N >> L;
  vector<string> s(N);
  for(i = 0; i < N; i++){
  	cin >> s.at(i);
  }
  
  sort(s.begin(),s.end());
  
  string ans = "";
  for(i = 0; i < s.size(); i++){
  	ans += s.at(i);
  }
  
  cout << ans << endl;
}

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

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

    int n;
    cin >> n;
    if (n % 2 == 0) {
        cout << (n - 1) / 2 << endl;
    } else {
        cout << n / 2 << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  string A, B;
  int c, root;
  cin >> A >> B;
  c = stoi(A+B);
  root = sqrt(c);
  if(root == sqrt(c)) cout << "Yes" << endl;
  else cout << "No" << endl;
}
  

Measured memory_bytes: 3616
#include<iostream>
#include<string>

using namespace std;

int main(void){
    int a=0, b=0, c=0, d=0;
    string ans="Balanced";

    cin >> a >> b >> c >> d;
  
  if(a + b > c + d)
    ans = "Left";
  if(a + b < c + d)
    ans = "Right";
    
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%s", $s);
$length = strlen($s);
$text = check_string($s, $length);
echo $text;
function check_string($s, $length)
{
    $output1 = -1;
    $output2 = -1;
    for ($i = 0; $i < $length; ++$i) {
        if (($i < $length - 1) && ($s[$i] == $s[$i + 1])) {
            $output1 = $i;
            $output2 = $i + 1;
        }
        if (($i < $length - 2) && ($s[$i] == $s[$i + 2])) {
            $output1 = $i;
            $output2 = $i + 2;
        }
    }
    if ($output1 == -1 && $output2 == -1) {
        echo $output1 . " " . $output2;
    } else {
        echo ($output1 + 1) . " " . ($output2 + 1);
    }
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const ll INF=1e18;
const int MOD=1e9+7;
const double pi=acos(-1);


int main(){
  ll n;
  cin >> n;
  ll ans=0;
  ll b=1;
  vector<ll>vec(n);
  rep(i,n) cin >> vec[i];
  rep(i,n-1){
    if(vec[i]==vec[i+1])b++;
    else{
      ans+=b/2;
      b=1;
    }
  }
  ans+=b/2;
  cout << ans << endl;
    
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        Map<Integer,Integer> ACnum = new HashMap<>();
        Map<Integer,Integer> wamp = new HashMap<>();
        int wa=0;
        for (int i = 0; i< M; i++){

            Integer p = Integer.valueOf(sc.nextInt());
            if (sc.next().equals("AC")){
                ACnum.put(p,1);
            }else{
                if(!ACnum.containsKey(p)){
                    if(!wamp.containsKey(p)){
                        wamp.put(p,1);
                    }else{
                        wamp.put(p,wamp.get(p) + 1);
                    }
                }
            }

        }
        for(int key:wamp.keySet()){
            if(ACnum.containsKey(key)){
                wa+=wamp.get(key);
            }
        }
        System.out.println(ACnum.size() + " " + wa);
    }
}


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

int main() {
    string S,T;
    cin >> S >> T;
    int a=0;
    for (int i=0;i<3;i++) {
        if (S.at(i) == T.at(i)) {
            a++;
        }
    }
    cout << a <<  endl;
     return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
#define lson rt<<1,l,M
#define rson rt<<1|1,M+1,r
#define PI acos(-1)
#define MM int M=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define fh(i,be,e) for(int i=head[be];~i;i=e[i].next)
#define fa(i,V) for(auto i:V)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
#define umap unordered_map
#define P pair<int,int>
#define SET set<int>
#define mp map<int,int>
#define mk make_tuple
#define low lower_bound
#define upp upper_bound
#define yn(key) out(key?"YES":"NO")
#define in(i) i+1,i+1+n
#define im(i) i+1,i+1+m
#define bffs(i) __builtin_ffs(i)
#define bcount(i) __builtin_popcount(i)
#define bone(i) ((1<<i)-1)
using namespace std;
const int INF=LLONG_MAX-1e10;
const int dx[]={0,0,-1,1},dy[]={-1,1,0,0};//up down left right
const int maxn=1e6+1e5;
const int mo_num=1e9+7;
int n,m,t,a[maxn],b[maxn],ans;

main()
{
    IOS
    string k;
    cin>>k;
    out(k=="ABC"?"ARC":"ABC")
    return 0;
}

Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.ABC_104
{
    class D
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            string s = Console.ReadLine();

            var dp = new long[s.Length + 1, 4];//文字数、いくつマークしたか?
            var keys = new char[3] { 'A', 'B', 'C' };
            int mask = 1000000000 + 7;
            for (int i = s.Length; i >= 0; i--)
            {
                for (int j = 0; j <= 3; j++)
                {
                    if (i == s.Length)//最後まで見た
                    {
                        dp[i, j] = j == 3 ? 1 : 0;
                    }
                    else
                    {
                        if (j == 3)
                        {
                            dp[i, j] = dp[i + 1, j];
                            dp[i, j] *= s[i] == '?' ? 3 : 1;
                            dp[i, j] %= mask;
                        }
                        else
                        {
                            int m1 = s[i] == '?' ? 3 : 1;
                            int m2 = s[i] == '?' || s[i] == keys[j] ? 1 : 0;
                            dp[i, j] = m1 * dp[i + 1, j] + m2 * dp[i + 1, j + 1];
                            dp[i, j] %= mask;
                        }
                    }
                }
            }
            /*for(int i = 0; i < dp.GetLength(0); i++)
            {
                string str = "";
                for(int j = 0; j < dp.GetLength(1); j++)
                {
                    str += dp[i, j].ToString() + " ";
                }
                Console.WriteLine(str);
            }*/
            Console.WriteLine(dp[0, 0]);
        }
    }
}

Measured memory_bytes: 14432
#include<iostream>

int main(void){
    int n, k;
    std::cin >> n >> k;
    int keta = 0;
    while(true){
	n /= k;
	keta++;
	if(n == 0){
	    break;
	}
    }
    std::cout << keta << std::endl;
    return 0;
}



Measured memory_bytes: 3620
#include<stdio.h>

int main(){
  int n,i,Array[250],left,right;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&Array[i]);
  }
  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,Array[i]);
    if((i/2)>=1)printf("parent key = %d, ",Array[i/2]);
    if((i*2)<=n)printf("left key = %d, ",Array[i*2]);
    if((i*2+1)<=n)printf("right key = %d, ",Array[i*2+1]);
    printf("\n");
  }
  return 0;
}
    



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

int main() {
    string s, t;
    cin >> s >> t;

    vector<int> S(26);
    vector<int> T(26);

    for (int i = 0; i < s.size(); ++i) {
        S[(s[i] - 'a')]++;
        T[(t[i] - 'a')]++;
    }

    sort(S.begin(), S.end());
    sort(T.begin(), T.end());

    for (int i = 0; i < 26; ++i) {
        if (S[i] != T[i]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
#define MAXN 200010
int dp[MAXN];
int cnt[10][10];
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int ans = 0;
    int c = 0;
    for(int i = 1; i <= n; i++){
        int a, b;
        b = i % 10;
        int x = i;
        while(x >= 10)
            x /= 10;
        a = x;
        ans += cnt[b][a];
        cnt[a][b]++;
        if(a == b) c++;
    }
    ans = ans * 2 + c;
    cout << ans << "\n";

    return 0;
}

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

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


int main(){
  int a;
  cin >> a;
  cout << a + a*a + a*a*a << endl;
  
  return 0;
} 

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>


using namespace std;


int main() {
	int H, W;

	vector<bool> col;
	vector<vector<bool>> row;

	cin >> H >> W;
	row.resize(H + 2);
	col.resize(W + 2);
	


	for (int i = 0; i < H +2; i++) {
		col[0] = false;
		col[H + 1] = false;
		for (int j = 1; j < W+1; j++) {
			if (i == 0 || i == H + 1) {
				col[j] = false;
			}
			else {
				char temp;
				cin >> temp;
				if (temp == '#')col[j] = true;
				else col[j] = false;
			}
		
		}
		row[i] = col;
	}

	bool result = true;


			for (int i = 1; i < H+1; i++) {
				for (int j = 1; j < W+1; j++) {
					if (row[i][j] == true) {

						if (row[i][j - 1] == true || row[i][j + 1] == true || row[i - 1][j] == true || row[i+1][j] == true ) {

						}
						else {
							result = false;
							break;
						}

					}

				}
				if (result == false) break;
			}
		
	if (result == true)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define all_acc(x) (x).begin(), (x).end(), 0LL
#define int long long
#define absSort(v) sort(a.begin(), a.end(), [](int i, int j) -> bool { return abs(i) < abs(j); });
using namespace std;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
using ll = long long;
double pi=3.14159265359;

//出力するよ
void output(vector<int> s)
{
    int n = s.size();
    for (int i = 0; i < n; i++)
    {
        if (i != 0)
            cout << " ";
        cout << s[i]; //<<endl;
    }
    cout << endl;
}

int MOD = pow(10, 9) + 7;

//各要素で最低操作回数を数える
pair<int,int> count(vector<int> a,vector<int> b){
    int n=a.size();
    int a_cnt=0,b_cnt=0;
    for(int i=0;i<n;i++){
        if(a[i]>b[i]){
            b_cnt+=(a[i]-b[i]);
        }
        if(a[i]<b[i]){
            if((b[i]-a[i])%2==0){
                a_cnt+=(b[i]-a[i])/2;
            }else{
                a_cnt+=(b[i]-a[i])/2 +1;
            }
        }
    }

    return make_pair(a_cnt,b_cnt);
}

signed main(){
    stack<char> st;
    string s; cin>>s;
    int n=s.length();

    for(int i=0;i<n;i++){
        //cout<<s[i]<<endl;
        if(st.size()==0) st.push(s[i]);
        else{
            char c=st.top();
            if(c=='S'&&s[i]=='T'){
                st.pop();
            }else st.push(s[i]);
        }
    }

    cout<<st.size()<<endl;
}

Measured memory_bytes: 3708
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>
#include <math.h>
#include <string>
#include <time.h>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=1e9+7;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
ll lef, rig, mid, best, x;

bool isok(ll T)
{
	ll sc=6*((T+1)/2)+5*(T/2);
	return sc>=x;
}

int main(void)
{
	cin>>x;
	lef=1; rig=1e16;
	while(lef<=rig)
	{
		mid=(lef+rig)/2;
		if(isok(mid)) best=mid, rig=mid-1;
		else lef=mid+1;
	}
	cout<<best; return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define hyperspeed ios::sync_with_stdio(false);cin.tie(NULL);
#define ll long long  
#define ull unsigned long long
#define ui unsigned int
#define li long int
#define uli unsigned long int
#define pb push_back
#define ld long double
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
const int MOD = 1e9+7;

void solve() {
    ll x;
    cin >> x;
    ll hap = 0;
    while(x>=500) {
        x-=500;
        hap+=1000;
    }
    while(x>=5) {
        x-=5;
        hap+=5;
    }
    cout << hap << endl;
}

int32_t main()
{
    hyperspeed
    int test=1;
    // cin >> test;
    while(test--) {
        solve();
    }
    return 0;
}

//--n1m5


Measured memory_bytes: 3608
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        // int n = Integer.parseInt(bf.readLine());
        StringTokenizer st = new StringTokenizer(bf.readLine());
        //
        int n = Integer.parseInt(st.nextToken());
        long k = Long.parseLong(st.nextToken());
        st = new StringTokenizer(bf.readLine());
         int[] a = new int[n]; for(int i=0; i<n; i++) a[i] = Integer.parseInt(st.nextToken());
         int[] next = new int[n];
         int[] prev = new int[200001];
         Arrays.fill(prev, -1);
         for(int i=0; i<2*n; i++) {
            int j = i%n;
            if(prev[a[j]] != -1) {
              next[prev[a[j]]] = j;
            }
            prev[a[j]] = j;
         }
        // System.out.println(Arrays.toString(next));
         int count = 1; int pointer = 0;
         while(true) {
           int nextval = next[pointer];
           if(nextval <= pointer) count++;
           pointer = nextval + 1;
           //System.out.println(pointer);
           if(pointer == n) break;
         }
         k %= count;
         if(k == 0) {
           out.println();
           out.close();
           System.exit(0);
         }
         count = 1;
         pointer = 0;
         while(true) {
           int nextval = next[pointer];
           if(nextval <= pointer) {
             if(count == k) {
               StringBuilder sb = new StringBuilder();
               for(int i=pointer; i<n; i++) {
                 if(next[i] <= i) sb.append(a[i] + " ");
                 else i=next[i];
               }
               out.println(sb.toString());
               out.close(); System.exit(0);
             }
             count++;
           }
           pointer = nextval + 1;
           if(pointer == n) break;
         }
        out.close(); System.exit(0);
    }
}


Measured memory_bytes: 65460
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <list>
#include <string>
using namespace std;
#define rep(i,n) for (ll i=0;i<(n);i++)
typedef long long ll;
bool aaa[11111111];
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

 
int main() {
  ll n,c,m,w=0,memo=0,sx=0,sy=1,ans=0,gx,gy;
  string ka,ss;
  cin>>n>>c>>m;
  if(c*m>=n)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  bool flag=true,flag1=false;
 
  
  
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1<<18,INF=1<<30;

int main(){
    
    int N;cin>>N;
    vector<int> A(N);
    ll ans=1;
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    int cnt=1,turn=N;
    for(int i=1;i<N;i++){
        if(A[i-1]<cnt*2-1){
            ans*=cnt;
            ans%=mod;
            turn--;
        }else cnt++;
    }
    
    for(int i=turn;i>=1;i--){
        ans*=i;
        ans%=mod;
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#include<iostream>
#include <iomanip>
using namespace std;
int main(){
    double r,p = 3.141592653589,s,l,d,k;
    cin>>r;
    s = r*r*p;
    l = 2*p*r; 
    d = s + 0.00000099999;
    k = l + 0.00000099999;
    cout<<fixed<<setprecision(10)<<d<<" "<<fixed<<setprecision(10)<<k<<endl;
    return 0;
}


Measured memory_bytes: 3272
import java.util.*;

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	
		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 max = 0;

		int maxnum = 0;
		int maxindex = 0;
		int sum = 0;
		for(int i=0; i<K; i++){
			sum += p[i];
		}
		maxnum = sum;
		
		for(int i=1; i<N-K+1; i++){
			sum -= p[i-1];
			sum += p[i+K-1];
			if(sum > maxnum) {
				maxnum = sum;
				maxindex = i;
			}
		}
		double kitaichisum = 0;
		for(int i=maxindex; i<maxindex+K; i++){
			kitaichisum += kitaichi(p[i]);
		}

		System.out.println(kitaichisum);

	}

	public static double kitaichi(int n){
		double k = (double)add(n)/(double)n;
		return k;
	}

	public static int add(int n) {
		int sum = 0;
		for(int i=1; i<=n; i++){
			sum += i;
		}
		return sum;
	}
}




Measured memory_bytes: 81188
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
using namespace std;
#define REP(i,a,n) for(int i = a ; i < n ; i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;

void solve(){
}

int main(){
  int n,m;

  while(cin>>n>>m,n||m){
    int s[m];
    rep(i,m){
      cin>>s[i];
    }

    bool flg = true;
    rep(i,n){
      rep(j,m){
        int x;
        cin>>x;
        s[j] -= x;
        if(s[j] < 0) flg = false;
      }
    }
    cout<<(flg ? "Yes" : "No")<<endl;
  }
}

Measured memory_bytes: 852
mod = 10**9 + 7
s = input()
n = len(s)
dp = [[0]*13 for i in range(n+1)]
dp[0][0] = 1
for i, si in enumerate(s):
  if si == '?':
    for ss in range(10):
      for j in range(13):
        dp[i+1][(j*10+ss)%13] += dp[i][j]
        dp[i+1][(j*10+ss)%13] %= mod
  else:
    ss = int(si)
    for j in range(13):
      dp[i+1][(j*10+ss)%13] += dp[i][j]
      dp[i+1][(j*10+ss)%13] %= mod
#print(dp)
print(dp[n][5])

Measured memory_bytes: 95940
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    n = int(input())
    a = [int(i) for i in input().split()]

    s = [0] * n
    for i in a:
        s[i - 1] += 1

    print(*s, sep='\n')


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 95452
#include<bits/stdc++.h>
using namespace std;
#define mx 1000000000000000000
#define ll long long int
//ll a[40001000];
//ll number[20],used[20];
int main()
{
    string a,b,c;
    cin >> a;
    ll count =0;
    for(ll i=0;i<a.size();i++)
    {
        if(i%2==0)
        {
            if(a[i]=='R'|| a[i]=='U'|| a[i]=='D')
                count =0;
            else
            {
                count =1;
                break;
            }
        }
        else if(i%2!=0)
        {
            if(a[i]=='L'|| a[i]=='U'|| a[i]=='D')
                count =0;
            else
            {
                count =1;
                break;
            }
        }
    }
    if(count==0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long

struct node { ll t,next; }a[200010];

ll head[100010],fa[100010],num[100010],h1[100010],h2[100010],st[100010],n,m,u,v,tot,top,ans;
bool bo[100010],flag;

inline ll rd()
{
	ll x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline void add(ll x,ll y) { a[++tot].t=y;a[tot].next=head[x];head[x]=tot; }

inline ll find(ll x)
{
	if (!fa[x]) return x;
	ll t=find(fa[x]);
	num[x]=num[x]^num[fa[x]];
	return fa[x]=t;
}

inline void pre(ll x,ll y)
{
	bo[x]=1;
	for (ll i=head[x];i;i=a[i].next)
	{
		ll t=a[i].t;
		if (t==y) continue;
		if (bo[t]) { u=x;v=t;if (num[u]==num[v]) flag=true; }
		else { num[t]=num[x]^1;pre(t,x); }
	}
}

inline void dfs(ll x,ll y)
{
	for (ll i=head[x];i;i=a[i].next)
	{
		ll t=a[i].t;
		if (t==y) continue;
		if (x==u&&t==v) continue;
		if (x==v&&t==u) continue;
		dfs(t,x);
		h1[x]+=h1[t];h2[x]+=h2[t];
	}
}

int main()
{
	n=rd();m=rd();tot=0;
	for (ll i=1;i<=m;i++)
	{
		ll x=rd(),y=rd();
		add(x,y);add(y,x);
	}
	num[1]=1;flag=false;pre(1,0);
	for (ll i=1;i<=n;i++)  h2[i]=(num[i])?1:-1;
	ll hh=0;
	for (ll i=1;i<=n;i++) hh+=h2[i];
	if (m==n-1) { if (hh) { puts("-1");return 0; } }
	else
	{
		if (flag)
		{
			if (hh&1) { puts("-1");return 0; }
			h2[u]-=(hh>>1);h2[v]-=(hh>>1);
			ans+=(ll)abs(hh>>1);
		}
		else
		{
			if (hh) { puts("-1");return 0; }
			h1[u]=1;h1[v]=-1;
		}
	}
	dfs(1,0);
	for (ll i=1;i<=n;i++)
	{
		if (!h1[i]) ans+=(ll)abs(h2[i]);
		else
		{
			if (h1[i]) h2[i]=-h2[i];
			st[++top]=h2[i];
		}
	}
	st[++top]=0;
	sort(st+1,st+top+1);
	hh=st[(top+1)>>1];
	for (ll i=1;i<=top;i++) ans+=(ll)abs(st[i]-hh);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 10112