akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
string str;
ll n, q, ans[100008], l, r;

int main(){
	cin >> n >> q >> str;
	ans[0] = 0;
	
	bool isa = false;
	
	for(ll i = 1; i <= n; i++){
		char c = str[i-1];
		ans[i] = ans[i-1];
		
		if(c == 'A'){isa = true;}
		else{
			if(isa && c == 'C'){ans[i]++;}
			isa = false;
		}
	}
	
	for(ll j = 1; j <= q; j++){
		cin >> l >> r;
		ll ans_buf = ans[r]-ans[l-1];
		if(l-2 >= 0 && (str[l-2] == 'A' && str[l-1] == 'C')){ans_buf--;}
		cout << ans_buf << endl;
	}
	
	
	
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

int main(){
    ll N;
    cin>>N;
    rep(h,1,3501)rep(n,1,3501){
        ll d = N*h*n;
        if(4*d/N-d/h-d/n <= 0)continue;
        if(d%(4*d/N-d/h-d/n) == 0){
            cout<<h<<" "<<n<<" "<<d/(4*d/N-d/h-d/n);
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
const t={input:require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/),n:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.n())}return a}else{const a=t.input[0];t.input.shift();return Number(a)}},s:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.s())}return a}else{const a=t.input[0];t.input.shift();return String(a)}},c:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.c())}return a}else{let a=t.input[0].split('');const b=a[0];a.shift();if(a.length>0){t.input[0]=a.join('')}else{t.input.shift()}return String(b)}},o:(...arg)=>{console.log(...arg)},abs:(a)=>{return Math.abs(a)},min:(...a)=>{return Math.min(...a)},max:(...a)=>{return Math.max(...a)},floor:(a)=>{return Math.floor(a)},asc:(ar:number[])=>{return ar.sort((a,b)=>{return a-b})},desc:(ar:number[])=>{return ar.sort((a,b)=>{return b-a})},sw:(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]}};
const main=()=>{
  let[a,b]=t.n(2)
  t.o(t.floor((b-1)%(a-1))==0?t.floor((b-1)/(a-1)):t.floor((b-1)/(a-1))+1)
}
main()

Measured memory_bytes: 7372
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	vector<pair<int, int>> vp;
	int n, m;
	cin >> n >> m;
	while (m--)
	{
		int a, b;
		cin >> a >> b;
		a++;
		vp.emplace_back(b, a);
	}
	sort(vp.begin(), vp.end());
	int cur = -1;
	int ans = 0;
	for (auto& p : vp)
	{
		if (p.second > cur) cur = p.first, ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1400
function Main(input) {
    // var MtNum = parseInt(input[0], 10); // 山の数
    var yama = input.slice(1).map(i => parseInt(i, 10));

    // 最初は一番目の山を入れる
    var max = yama[0];
    // console.log('yama: %o', yama);

    var sum = 1;

    for (var i = 1; i < yama.length; i++) {
        max = max < yama[i-1] ? yama[i-1] : max;
        // console.log('max: %s', max);
        if (max <= yama[i]) {
            // console.log('%s番目の山からは見えます', i);
            sum++;
        }
    }

    console.log(sum);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 7372
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    A,B,C = inputMap()
    
    tot = A+B+C
    tmp = tot - 7
    if max(A,B,C) == 7 and min(A,B,C) == 5 and tmp == 10:
        print("YES")
    else:
        print("NO")
    
if __name__ == "__main__":
	main()


Measured memory_bytes: 38640
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

namespace CountingSort
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(ReadLine());
            var array = ReadLine().Split(' ').Select(int.Parse).ToArray();
            var result = new int[n];
            var k = array.Max();

            MyCountingSort(array, result, k);

            WriteLine(string.Join(" ", result));
        }

        private static void MyCountingSort(int[] array, int[] result, int k)
        {
            // データの個数をカウント
            var count = new int[k + 1];

            for (var i = 0; i < array.Length; i++)
            {
                // 対象の個数をカウントアップ
                count[array[i]]++;
            }

            for (var i = 1; i <= k; i++)
            {
                count[i] += count[i - 1];
            }

            for (var j = result.Length - 1; j >= 0; j--)
            {
                result[count[array[j]] - 1] = array[j];
                count[array[j]]--;
            }
        }
    }
}


Measured memory_bytes: 179044
#include <cmath>
#include <iomanip>
#include <iostream>

using namespace std;

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

  if (x > a * a * b / 2)
  {
    double at = 2 * double(a * a * b - x) / pow(a, 3);

    double theta = atan(at);
    theta = theta * 180 / M_PI;

    cout << fixed << setprecision(10) << theta << endl;
  }
  else
  {
    double at = a * b * b / double(2 * x);

    double theta = atan(at);
    theta = theta * 180 / M_PI;

    cout << fixed << setprecision(10) << theta << endl;
  }

  return 0;
}

Measured memory_bytes: 4192
import java.math.BigInteger;
import java.util.*;
public class Main {





public static void main(String[] args)
{
	Scanner sc=new Scanner(System.in);
	int n=sc.nextInt();
	int c=sc.nextInt();
	
pair arr[]=new pair[n];
pair cc[]=new pair[c];
for(int i=0;i<n;i++) {
	int x=sc.nextInt();
	int y=sc.nextInt();
	pair p=new pair(x,y);
	arr[i]=p;
}
for(int i=0;i<c;i++) {
	int x=sc.nextInt();
	int y=sc.nextInt();
	pair p=new pair(x,y);
	cc[i]=p;
}
long ans=0;

for(int i=0;i<n;i++) {
	long min=Long.MAX_VALUE;
	for(int j=0;j<c;j++) {
					long dis=Math.abs(arr[i].x-cc[j].x)+Math.abs(arr[i].y-cc[j].y);
					if(dis<min) {
						min=dis;
						ans=j;
					}
	}
	System.out.println(ans+1);
}
	

}

}

class pair{
	int x,y;
	pair(int x,int y){
		this.x=x;
		this.y=y;
	}
}


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

#define mp make_pair
#define fst first
#define snd second

using namespace std;

typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;
typedef pair<int,int> pii;
typedef pair<i64,int> pli;
typedef pair<int,i64> pil;
typedef pair<i64,i64> pll;
typedef vector<int> vi;
typedef vector<i64> vl;

template <typename T>
T id(T b) {return b;};
template <class It>
bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It>
bool any(It f,It l){return std::any_of(f,l,id<bool>);}

const int MAX_N = 200000;
int l;
int a[MAX_N];
i64 dp[MAX_N+1][5] = {};

int main()
{
  cin >> l;
  for (int i = 0; i < l; ++i) {
    cin >> a[i];
  }

  for (int i = 0; i < l; i++) {
    dp[i+1][0] = dp[i][0] + a[i];
    dp[i+1][1] = *min_element(dp[i],dp[i]+2) + (a[i]==0?2:a[i]%2==1);
    dp[i+1][2] = *min_element(dp[i],dp[i]+3) + (a[i]%2==0);
    dp[i+1][3] = *min_element(dp[i],dp[i]+4) + (a[i]==0?2:a[i]%2==1);
    dp[i+1][4] = *min_element(dp[i],dp[i]+5) + a[i];
    /*
    for (int j = 0; j < 4; j++)
      printf("dp[%d][%d]=%ld\n",i,j,dp[i][j]);
    */
  }

  i64 m = INT64_MAX;
  for (int i = 0; i < 5; i++) {
    m = min(m, dp[l][i]);
    //printf("dp[%d][%d]=%ld\n",l,i,dp[l][i]);
  }

  cout << m << endl;

  return 0;
}


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

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != t[i]) ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3920
#include<bits/stdc++.h>
using namespace std;
int main()
{
    unsigned long long q,z;
    double w;
    scanf("%llu %lf",&q,&w);
    w+=1e-6;
    z=w*100;
    q*=z;
    printf("%llu\n",q/100);
    return 0;
}


Measured memory_bytes: 3820
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

#define F first
#define S second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int a, b;
    cin >> a >> b;
    if (a + b < 24) {
        cout << a + b << endl;
    }else{
        cout << a + b - 24 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/*---------------Go Code GO---------------*/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

template<typename T>
using Order_Set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;
//(order) Set.order_of_key(); (pointer) Set.find_by_order();

#define     PI              acos(-1.0)
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define     precision(a)    fixed<<setprecision(a)
#define     endl            '\n'
#define     Flush           cout<<flush
#define     LLMX            0x3fffffffffffffff

vector<int> boss[200005];


int main()
{
    long long N,M, ans =0;
    cin>>N;
    for(int i=2; i<=N; i++)
    {
        cin>>M;
        boss[M].push_back(i);
    }
    for(int i=1; i<=N; i++)
    {
        cout<<boss[i].size()<<endl;
    }


    return 0;
}


Measured memory_bytes: 14568
N = int(input())
H = list(map(int, input().split()))

ans = 0
cnt = 0
for i in range(1,N):
    if H[i-1] >= H[i]:
       cnt += 1
    else:
        ans = max(ans,cnt)
        cnt = 0
ans = max(ans,cnt)
print(ans)

Measured memory_bytes: 14224
#include<stdio.h>
int main()
{
    int sei;
    int p;

    scanf("%d",&sei);


p=sei%10;

if(p==2||p==4||p==5||p==7||p==9)
//if(sei==2||sei==4||sei==5||sei==7||sei==9)
{
    printf("hon\n");
}

else if(p==0||p==1||p==6||p==8)
//if else(sei==0||sei==1||sei==6||sei==8)
{
    printf("pon\n");
}
else
{
    printf("bon\n");
}
    return 0;
}

Measured memory_bytes: 1636
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

#define ll long long int
#define ull unsigned long long int

#define INF 100000000000L

using namespace std;

int main(){
    int A,B;
    cin >> A >> B;
    int max = 0;
    if(2*A -1 > max){
        max = 2*A-1;
    }
    if(2*B-1 > max){
        max = 2*B-1;
    }
    if(A+B > max){
        max = A+B;
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a <= b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first; printf("\n"); }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first; printf(" "); put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first; printf("\n"); putn(rest...); }

int main() {
	string s;
	cin >> s;
	int n = s.size(); 
	s.push_back('A');
	if (n == 1) {
		put(0);
		return 0;
	}
	int res = 0;
	vector<vector<int>> dp(n+1, vector<int>(2, 0));
	dp[0][0] = 1;
	dp[0][1] = 0;
	dp[1][1] = 1;
	if (s[0] != s[1]) {
		dp[1][0] = 2;
	} else {
		dp[1][0] = 0;
	}
	FOR(i,1, n - 1) {
		if (s[i + 1] != s[i]) {
			dp[i+1][0] = max(dp[i][0] , dp[i][1])+1;
		}else{
			dp[i+1][0] = dp[i][1]+1;
		}
		if (i>1&&s[i + 1] == s[i - 1] && s[i] == s[i - 2]) {
			dp[i + 1][1] = max(dp[i-1][0], dp[i-1][1]) + 1;
		} else {
			if (dp[i - 1][0] == 0) {
				dp[i + 1][1] = 0;
			} else {
				dp[i + 1][1] = dp[i - 1][0] + 1;
			}
			
		}
	}
	REP(i, n) {
		REP(j, 2) {
			chmax(res, dp[i][j]);
		}
	}
	put(res);
	return 0;
}

Measured memory_bytes: 11396
import std.stdio;
import std.array;
import std.conv;
import std.string;
void main(){
  string s;
  int[] heights;
  while((s = readln()) != "\n" && !stdin.eof() ){
    s = chomp(s);
    heights ~= to!int(s);
  }
  heights.sort;
  heights.reverse;
  for(int i = 0; i < 3; i++){
    writeln(heights[i]);
  }
}

Measured memory_bytes: 972
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
typedef struct P
{
	int y,x,c,d;//0:E 1:S 2:W 3:N
	bool operator <(const P &a)const{return c>a.c;};
}P;
P t;
int W,H,S[30][30],C[5],mv[4][2]={{0,1},{1,0},{0,-1},{-1,0}},F[30][30][4];

P set(int nd)
{
	int c=(nd-t.d+4)%4;
	P r=t;
	r.y+=mv[nd][0];
	r.x+=mv[nd][1];
	r.d=nd;
	r.c+=S[t.y][t.x]==c?0:C[c];
	return r;
}

int main()
{
	for(;scanf("%d%d",&W,&H),W;)
	{
		memset(F,0x7f,sizeof(F));
		for(int i=0;i<H;i++)
			for(int j=0;j<W;j++)
				scanf("%d",&S[i][j]);
		for(int i=0;i<4;i++)
			scanf("%d",&C[i]);
		priority_queue<P>Q;
		t.x=t.y=t.c=t.d=0;
		Q.push(t);
		int R=1000000;
		for(;!Q.empty();)
		{
			t=Q.top();Q.pop();
			int Y=t.y,X=t.x;
			if(Y==H-1&&X==W-1){R=min(R,t.c);continue;}
			if(X<0||X>=W||Y<0||Y>=H||F[Y][X][t.d]<t.c)continue;
			F[Y][X][t.d]=t.c;
			for(int i=0;i<4;i++)
			{
				P ins=set(i);
				Y=ins.y,X=ins.x;
				if(X<0||X>=W||Y<0||Y>=H||F[Y][X][ins.d]<=ins.c)continue;
				Q.push(ins);
			}
		}
		printf("%d\n",R);
	}
}

Measured memory_bytes: 1200
package main

import (
	"fmt"
	"sort"
)

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	list := sort3(a, b, c)
	max := list[2]
	total := 3*max - (a + b + c)
	totalO := 3*(max+1) - (a + b + c)
	if total%2 == 0 {
		fmt.Println(total / 2)
	} else {
		fmt.Println(totalO / 2)
	}

}

func sort3(a, b, c int) []int {
	list := []int{a, b, c}
	sort.Sort(sort.IntSlice(list))
	return list
}


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

// r がグーを出すことを、s のときはチョキを出すことを、p のときはパー



signed main() {
	int n, k, r, s, p;
	ll sum = 0;
	string t, str;

	cin >> n >> k >> r >> s >> p >> t;

	for (int i = 0; i < t.size(); i++) {
		if (t[i] == 'r') {
			if (i - k >= 0 && str[i - k] == 'p') {
				str += 'a';
			}
			else {
				str += 'p';
				sum += p;
			}
		}
		else if (t[i] == 's') {
			if (i - k >= 0 && str[i - k] == 'r') {
				str += 'a';
			}
			else {
				str += 'r';
				sum += r;
			}
		}
		else if (t[i] == 'p') {
			if (i - k >= 0 && str[i - k] == 's') {
				str += 'a';
			}
			else {
				str += 's';
				sum += s;
			}
		}
	}

	//cout << str << endl;

	//for (int i = 0; i < t.size(); i++) {
	//	if (t[i] == 'r') {
	//		if (i+k < (int)t.size() && t[i + k] == 'r') {

	//		}
	//		else {
	//			sum += p;
	//		}
	//	}
	//	else if (t[i] == 's') {
	//		if (i + k < (int)t.size() && t[i + k] == 's') {

	//		}
	//		else {
	//			sum += r;
	//		}
	//	}
	//	else if (t[i] == 'p') {
	//		if (i + k < (int)t.size() && t[i + k] == 'p') {

	//		}
	//		else {
	//			sum += s;
	//		}
	//	}
	//}

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 1000000007
#define SIZE 10005
#define PI 	3.14159265358979323846

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; } //最小公倍数

long double input(){
  ll a;
  cin >> a;
  return a;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    long double a[20000];
    REP(i,n)cin >> a[i];
    sort(a,a+n);
    long double ans=a[0]; 
    FOR(i,1,n){
      ans += a[i];
      ans /= 2;
    }
    printf("%.12Lf\n",ans);
}

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int main(){
    string s;
    int k;
    cin >> s >> k;
    int n = s.size();
    vector<string>ans;
    rep(i, 0, n){
        rep(j, 1, k+1){
            ans.push_back(s.substr(i, j));
        }
    }
    sort(ans.begin(),ans.end());
    ans.erase(unique(ans.begin(),ans.end()),ans.end());
    cout << ans[k-1] << endl;
}

Measured memory_bytes: 4320
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
int main(int argc, char* argv[]) {
    int n,i;
    cin >> n >> i;
    cout << n - i + 1 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int r, c, sum, r_sum, c_sum;  // r：行, c：列
	int i, j;
	int cell[100][100];
	
	for (i = 0; i < 100; i++){
		for (j = 0; j < 100; j++){
			cell[i][j] = 0;
		}
	}
	
	scanf("%d %d", &r, &c);
	
	for (i = 0; i < r; i++){
		for (j = 0; j < c; j++){
			scanf("%d", &cell[i][j]);
		}
	}
	c_sum = 0;
	for (i = 0; i < r; i++){
		for (j = 0; j < c; j++){
			printf("%d ", cell[i][j]);
			c_sum += cell[i][j];
		}
		printf("%d\n", c_sum);
		c_sum = 0;
	}
	
	sum = 0;
	r_sum = 0;
	for (i = 0; i < c; i++){
		for (j = 0; j < r; j++){
			r_sum += cell[j][i];
		}
		sum += r_sum;
		printf("%d ", r_sum);
		r_sum = 0;
	}
	printf("%d\n", sum);
	
	return 0;
}



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

#define fi first
#define se second
#define pb push_back
#define ll long long

const int N = 5e4 + 7;

using namespace std;

int n , m;
ll used[N];
int cnt  , sum  , a , x , y , mn = 1e9;
int main(){
    ios_base::sync_with_stdio(false);
   cin >> n >> m;
   map<int , int>mp;
   vector<int>v;
   for( int i = 1;i <= m;i ++ )
    cin >> a , mp[a] ++;
   for( int i = 0;i <= 1000;i ++ )
    if( !mp[i] ){
        if( abs(n - i) < mn )
            mn = abs(n - i) , cnt = i;
    }
    cout << cnt;
}


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

using namespace std;

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

	int* ar1;
	ar1 = new int[n];
	
	for (int i = 0; i < n; i++) {
		ar1[i] = i + 1;
	}

	int w1=0;

	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		if (t != ar1[i]) {
			w1++;
		}
	}

	if (w1 == 0 || w1 == 2) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
typedef long long int ll;
const long long int m=pow(10,9)+7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,ans=0;
    cin>>n;
    int a[n+1],b[n];
    for(int i=0;i<n+1;i++)
        cin>>a[i];
    for(int i=0;i<n;i++)
        cin>>b[i];
    for(int i=0;i<n;i++)
    {
        if(a[i]<b[i])
        {
            ans+=a[i];
            b[i]-=a[i];
            a[i]=0;
            //cout<<a[i]<<" "<<b[i]<<endl;
        }
        else
        {
            ans+=b[i];
            a[i]-=b[i];
            b[i]=0;
            //cout<<a[i]<<" "<<b[i]<<endl;
        }
        if(a[i+1]<b[i])
        {
            ans+=a[i+1];
            b[i]-=a[i+1];
            a[i+1]=0;
            //cout<<a[i]<<" "<<b[i]<<endl;
        }
        else
        {
            ans+=b[i];
            a[i+1]-=b[i];
            b[i]=0;
            //cout<<a[i]<<" "<<b[i]<<endl;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4376
<?php
fscanf(STDIN, "%d %d", $count, $index);
$totalInsertCount = 0;
for($i = 0; $i < $count; $i++) {
    fscanf(STDIN, "%d %d", $target, $insertCount);
    if (!isset($insertCounts[$target])) $insertCounts[$target] = 0;
    $insertCounts[$target] += $insertCount;
}

ksort($insertCounts);

foreach ($insertCounts as $key => $insertCount) {
    $totalInsertCount += $insertCount;
    if($index <= $totalInsertCount) {
        echo $key;
        return;
    }   
}


Measured memory_bytes: 8952
#include <cstdio> 
#include<iostream>
using namespace std;
int N,C,tmp; 
int s[100000],t[100000],c[100000]; 
int sm[200002]; int tt[200002]; 
int main() { 
	cin >> N >> C;
	for (int i = 0; i < N; i++) {
		cin >> tmp; s[i] = tmp; cin >> tmp; t[i] = tmp; cin >> tmp; c[i] = tmp;
	}
	for(int i=1;i<=C;i++) { 
		for(int j=0;j<200002;j++)tt[j]=0; 
		for(int j=0;j<N;j++)if(c[j]==i)tt[s[j]*2-1]++,tt[t[j]*2]--; 
		for(int j=1;j<200002;j++)tt[j]+=tt[j-1]; 
		for(int j=0;j<200002;j++)if(tt[j]>0)sm[j]++; }
	int mx=0; for(int j=0;j<200002;j++)if(mx<sm[j])mx=sm[j]; printf("%d\n",mx);

	//system("pause");
}

Measured memory_bytes: 2944
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let k: usize = scan(tokens);
    let mut ans: usize = 0;
    for a in 1..=k {
        for b in 1..=k {
            let ab = gcd(a, b);
            for c in 1..=k {
                ans += gcd(ab, c);
            }
        }
    }
    println!("{}", ans);
}

fn gcd(mut x: usize, mut y: usize) -> usize {
    while y != 0 {
        let r = x % y;
        x = y;
        y = r;
    }
    x
}


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

int main() {

    int N;
    cin >> N;

    int ans = 0;
    for (int i=1; i<10; i++) {
        if (N <= i * 111) {
            ans = i * 111;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

	int a, b, coin = 0;
	cin >> a >> b;


	for (int i = 0; i < 2; i++){
		if (a > b){
			coin += a;
			a--;
		}
		else{
			coin += b;
			b--;
		}
	}

	cout << coin << endl;

	return 0;
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C: Colorful Leaderboard
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int C = 9;
const int INF = 1 << 30;

const int RNS[C] = {
  400, 800, 1200, 1600, 2000, 2400, 2800, 3200, INF
};

/* typedef */

/* global variables */

int cs[C];

/* subroutines */

/* main */

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

  for (int i = 0; i < n; i++) {
    int ai;
    cin >> ai;

    int k = upper_bound(RNS, RNS + C, ai) - RNS;
    cs[k]++;
  }

  int minc = 0;
  for (int i = 0; i < C - 1; i++)
    if (cs[i]) minc++;

  printf("%d %d\n", max(minc, 1), minc + cs[C - 1]);
  return 0;
}


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


#define debug(n) cerr << #n << ':' << n << endl;
#define ll long long

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

int main(){
  ll N,M;cin >> N >> M;
  string S,T;cin >> S >> T;
  ll L = (N * M) / gcd(N, M);
  ll n = L / N, m = L / M;
  unordered_map<ll, char>X;
  for(int i = 0; i < N; ++i){    
    X[i * n] = S[i];
  }
  bool dif = false;
  for(int i = 0; i < M; ++i){
    if(X.count(i * m) == 0)continue;
    if(X[i * m] != T[i]){
      dif = true;
    }
  }
  if(dif)cout << -1 << endl;
  else cout << L << endl;
  return 0;
}


Measured memory_bytes: 4260
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
 
int L, N = 0;
vector<vector<int>> edge;

int main(void){
	
	scanf("%d", &L);
    while(1 << N <= L) ++N;
    
    for(int i = 1; i < N; ++i){
        edge.push_back({i, i + 1, 1 << (i - 1)});
        edge.push_back({i, i + 1, 0});
    }
	
	int corrent = (1 << (N - 1)) - 1;
	
	for(int i = N - 1; i >= 1 && corrent != L - 1; i--){
	    
	    int add = 1 << (i - 1);
	    
	    if(corrent + add <= L - 1){
	        edge.push_back({i, N, corrent + 1});
	        corrent += add;
	    }
	    
	}
	
	printf("%d %d\n", N, (int)edge.size());
	for(auto i : edge) printf("%d %d %d\n", i[0], i[1], i[2]);
	
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    // メインプログラムここから
    ll n; cin>>n;
    vector<ll>L(2*n);
    rep(i,2*n){
        cin>>L[i];
    }
    sort(L.begin(),L.end());
    ll ans=0;
    rep(i,n){
        ans+=L[i*2];
    }
    cout<<ans<<endl;
    
    // ここまで
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  if ((A + B) % 2 == 0) {
    cout << (A + B) / 2 << endl;
  }
  else {
    cout << "IMPOSSIBLE" << endl;
  }
}

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

#define N 300000

int main(void){
  bool eratos[N];
  eratos[0] = eratos[1] = false;
  for(int i = 2; i < N; i++){ eratos[i] = true; }
  for(int i = 2; i * i < N; i++)
    if(eratos[i])
      for(int j = i + i; j < N; j += i)
        eratos[j] = false;

  while(true){
    int n;
    cin >> n;
    if(n == 0){ break; }

    int ans = 0;
    for(int i = n + 1; i <= 2 * n; i++)
      if(eratos[i])
        ++ans;
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 3304
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
	int n,x=0;cin>>n;
	for(int i=1;i<=n;i++){
		x=(x*10+7)%n;
		if(!x){
			cout<<i<<endl;
			return 0;
		}
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N;
vector<ll> A, B;
ll sumA, sumB;
int main()
{
    cin >> N;
    A.resize(N);
    B.resize(N);
    for (auto &val : A)
    {
        cin >> val;
    }
    for (auto &val : B)
    {
        cin >> val;
    }
    ll res = 0;
    for (int i = 0; i < N; i++)
    {
        if (A[i] < B[i])
        {
            res += (B[i] - A[i]) / 2;
        }
        else
        {
            res -= (A[i] - B[i]);
        }
    }
    if (res >= 0)
    {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

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

#define rep(i, x, n) for(int i=(x);i<(n);i++)
#define reps(i, x, n) for(int i=(x);i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;
//八方向を見るのに使うと便利(楽)
const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  string n;
  cin >> n;
  bool memo = false;
  rep(i, 1, n.size()){
    if(n[i] != '9'){
      memo = true;
    }
  }
  int ans = n[0] - '0' + 9 * (n.size() - 1);
  cout << (memo ? ans - 1 : ans) << '\n';
  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define LL long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
LL n,k,ans;
int main()
{
	cin>>n>>k;
	LL cnt=0;
	if(k&1){
		for(LL i=k;i<=n;i+=k) cnt++;
		ans=cnt*cnt*cnt;
		cout<<ans<<endl; 
	}
	else{
		for(LL i=k;i<=n;i+=k) cnt++;
		ans=cnt*cnt*cnt;
		cnt=0;
		for(LL i=(k>>1);i<=n;i+=k) cnt++;
		ans+=cnt*cnt*cnt;
		cout<<ans<<endl;
	}
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
const int N = 200005;
int n;
vector<pair<int, int> > v;
ll memo[2000][2000];
ll solve(int *arr, int i, int l, int r) {
if (i==n) {
return 0LL;
}
if (memo[l][r] != -1) {
return memo[l][r];
}
ll ans1 = solve(arr, i + 1, l + 1, r) + (1LL * v[i].first * abs(v[i].second - l));
ll ans2 = solve(arr, i + 1, l, r - 1) + (1LL * v[i].first * abs(v[i].second - r));
return memo[l][r] = max(ans1, ans2);
 
}
 
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
cin >> n;
int arr[2005];
for (int i = 0; i < n; i++)
cin >> arr[i];
for (int i = 0; i < n; i++) {
v.push_back({arr[i], i});
}
memset(memo, -1, sizeof memo);
sort(v.begin(), v.end());
reverse(v.begin(), v.end());
// for (int i = 0; i < n; i++) {
// cout << v[i].first << " " << v[i].second << endl;
// }
ll ans = solve(arr, 0, 0, n - 1);
cout<<ans<<endl;
return 0;
 
}

Measured memory_bytes: 35060
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def prime_table(n):
    t = [True] * (n + 1)
    t[0] = False
    t[1] = False

    i = 2
    while i * i <= n:
        for ii in range(2 * i, n + 1, i):
            t[ii] = False
        i += 1
    return [x for x, i in enumerate(t) if i == True]


def solve(N: int):
    res = []
    for p in prime_table(55555):
        if p % 5 == 1:
            res.append(p)
            if len(res) == N:
                break
    return res


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    result = solve(N)
    if isinstance(result, Iterable):
        result = ' '.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 6192
#include<bits/stdc++.h>
using namespace std;
#define ll int
 #define watch(x) cerr<<(#x)<<" is "<<x<<nl;
#define f(i,a,b) for(ll i=a; i<b; i++)
#define fr(i,a,b) for(ll i=a; i>=b; i--)
#define mp make_pair
#define ff first 
#define ss second
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mem(v,a) memset((v),a,sizeof(v));
#define mll map<ll,ll>
#define vll vector<ll>
#define nl endl

void solve(){
ll x;
cin>>x;

	vll ff;
	for(int i=1;i*i*i<=x;i++){
	if(x%i==0) {
	 ff.pb(i);	
	    }	
      }
 for(int j=0;j<(int)ff.size();j++){
 for(int i=1;i*i*i*i+i*i*i*(i-ff[j])+i*i*(i-ff[j])*(i-ff[j])+i*(i-ff[j])*(i-ff[j])*(i-ff[j])+(i-ff[j])*(i-ff[j])*(i-ff[j])*(i-ff[j])<=x;i++){
	 
	 //~ cout<<i*i*i*i+i*i*i*(i-ff[j])+i*i*(i-ff[j])*(i-ff[j])+i*(i-ff[j])*(i-ff[j])*(i-ff[j])+(i-ff[j])*(i-ff[j])*(i-ff[j])*(i-ff[j])<<nl;
	  if(i*i*i*i+i*i*i*(i-ff[j])+i*i*(i-ff[j])*(i-ff[j])+i*(i-ff[j])*(i-ff[j])*(i-ff[j])+(i-ff[j])*(i-ff[j])*(i-ff[j])*(i-ff[j]) == x/ff[j])
	   { cout<<i<<" "<<i-ff[j]<<nl; return ;}
 }
}

 for(int j=0;j<(int)ff.size();j++){
 for(int i=1;i*i*i*i+i*i*i*(i+ff[j])+i*i*(i+ff[j])*(i+ff[j])+i*(i+ff[j])*(i+ff[j])*(i+ff[j])+(i+ff[j])*(i+ff[j])*(i+ff[j])*(i+ff[j])<=x;i++){
	 

	  if(i*i*i*i+i*i*i*(i+ff[j])+i*i*(i+ff[j])*(i+ff[j])+i*(i+ff[j])*(i+ff[j])*(i+ff[j])+(i+ff[j])*(i+ff[j])*(i+ff[j])*(i+ff[j]) == x/ff[j])
	   { cout<<i<<" "<<i+ff[j]<<nl; return ;}
 }
}



}

signed main(){  
 ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t; 
t=1;
//~ cin>>t; 
for(int _=0;_<t;_++){
      solve();
// cout<<"Case # "<<t<<;
}
return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int a[100001],f[100001]={0};
int main()
{
	int  n,i,k,j,m;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(i=1;i<=n;i++)
	{
		if(i==2)
		{
			f[i]=abs(a[i-1]-a[i])+f[i-1];
		}
		else if(i>=3)
		{
			f[i]=min(abs(a[i-1]-a[i])+f[i-1],abs(a[i-2]-a[i])+f[i-2]);
		}
	}
	printf("%d",f[n]);
}

Measured memory_bytes: 1024
import java.math.BigInteger;
import java.util.Scanner;
import java.io.PrintWriter;
import java.util.ArrayList;

public class Main {
	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int V = sc.nextInt();
		int E = sc.nextInt();
		ArrayList<Integer>[] g = new ArrayList[V];
		for (int i = 0; i < V; ++i) {
			g[i] = new ArrayList<>();
		}
		for (int i = 0; i < E; ++i) {
			int s = sc.nextInt();
			int t = sc.nextInt();
			g[s].add(t);
		}
		vis = new boolean[V];
		sort(g);
		for (int i = lis.size() - 1; i >= 0; --i) {
			System.out.println(lis.get(i));
		}
	}

	static boolean[] vis;
	static ArrayList<Integer> lis = new ArrayList<>();

	static void sort(ArrayList<Integer>[] g) {
		int n = g.length;
		for (int i = 0; i < n; ++i) {
			if (!vis[i]) {
				dfs(i, -1, g);
			}
		}
	}

	static void dfs(int cur, int pre, ArrayList<Integer>[] g) {
		for (int to : g[cur]) {
			if (pre != cur && !vis[to]) {
				dfs(to, cur, g);
			}
		}
		vis[cur] = true;
		lis.add(cur);
	}
}

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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define bf(i,s) for(int i = head[s]; i; i = e[i].next)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define VI vector<int>
#define sf scanf
#define pf printf
#define fp freopen
#define SZ(x) ((int)(x).size())
#ifdef MPS
#define D(x...) printf(x)
#else
#define D(x...)
#endif
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db Inf = 1e20;
const db eps = 1e-9;

void gmax(int &a,int b){a = (a > b ? a : b);}
void gmin(int &a,int b){a = (a < b ? a : b);}

int N, k, ans, cnt[100050];

int main()
{
	cin >> N >> k;
	fo(i,1,N) cnt[i%k] ++;
	if(k&1) cout << (ll)(N/k)*(N/k)*(N/k) << endl;
	else cout << (ll)cnt[k/2]*cnt[k/2]*cnt[k/2]+(ll)(N/k)*(N/k)*(N/k) << endl;
	return 0;
}

Measured memory_bytes: 640
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}

fn main() {

    let n: u32 = read();
    let k: u32 = read();
    let h: Vec<u32> = (0..n).map(|_| read()).collect();

    println!("{}", h.iter().filter(|x| **x >= k).count());
    
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>

using namespace std;
#define ll long long
#define pb push_back

int main() {
  int N, M, X, Y, x, y;
  cin >> N >> M >> X >> Y;
  int max_x = X, min_y = Y;
  bool flag = false;
  for(int i=0; i<N; i++){
      cin >> x;
      max_x = max(x, max_x);
  }
  for(int i=0; i<M; i++){
      cin >> y;
      min_y = min(y, min_y);
  }
//   cout << min_y << " " << max_x << " ";
  
  if(X < min_y){
      flag = true;
  }
  if(max_x >= min_y){
      flag = false;
  }

  if(flag){
      cout << "No War" << endl;
  } else {
      cout << "War" << endl;
  }

}


Measured memory_bytes: 256
N, K = map(int, input().split())
box = [n for n in range(N+1)]
MOD = int(1e9) + 7
ans = 0

# 部分和
bubu = []
bubu.append(box[0])
for el in range(N+1):
    if el == 0:
        continue
    else:
        bubu.append(bubu[el - 1] + box[el])

rbubu = []
rbubu.append(box[-1])
for el in reversed(range(N+1)):
    if el == N:
        continue
    else:
        rbubu.append(rbubu[-1] + box[el])

for i in range(K, N+2):
    temp = (rbubu[i-1] - bubu[i-1] + 1) % MOD
    ans += temp
    ans = ans % MOD

print(ans)


Measured memory_bytes: 94220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
#define mp make_pair
#define X  first
#define Y  second
#define N 100000

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,i,x;
    x=0;
    cin>>n;

    int arr[n+1];

    for(i=1;i<=n;i++)
    {
        cin>>arr[i];
    }
    for(i=1;i<=n;i+=2)
    {
        if(arr[i]&1)
        {
            x++;
        }
    }
    cout<<x;

    return 0;
}


Measured memory_bytes: 3608
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

//#define _USE_MATH_DEFINES
//#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>
#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 1000000007; // 10000000000000007ll;

const double eps = 1e-8;

const i64 MAXN = 52;
const i64 MAXM = 20004;

i64 n;
i64 a[MAXN];

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    i64 a, b, c;
    cin >> a >> b >> c;

    if ((a == b && a != c) || (a == c && a != b) || (b == c && a != c)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
#define MOD 1000000007
int m, n;
char a[1001][1001];
ll dp[1001][1001];
 
int main() {
        ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
 
        cin >> m >> n;
        for (int i = 1; i <= m; i++)
                for (int j = 1; j <= n; j++)
                        cin >> a[i][j];
 
        for (int i = 1; i <= m; i++)
                for (int j = 1; j <= n; j++)
                        if (i == 1 && j == 1 && a[i][j] == '.')
                                dp[i][j] = 1;
                        else if (a[i][j] == '.')
                                dp[i][j] = (dp[i][j-1] + dp[i-1][j]) % MOD;
        cout << dp[m][n] % MOD << endl;
 
        return 0;
}

Measured memory_bytes: 9088
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <cstring>
#include <queue>
#include <math.h>
using namespace std;
typedef long long ll;
int sw[2005],sb[2005],uw[2005],ub[2005];
int sw2[2005],sb2[2005],uw2[2005],ub2[2005];
int w[2005][2005],b[2005][2005];
int n,k,ans=0;
int main(void){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        int x,y;
        char c;
        cin>>x>>y>>c;
        x=(((x/k)%2+(y/k)%2)%2)*k+x%k;
        y=y%k;
        if(c=='W')w[y][x]++;
        else b[y][x]++;
    }
    
    for(int i=0;i<k;i++){
        for(int j=0;j<k;j++){
            ub[j]+=b[i][j];
            uw[j]+=w[i][j];
        }
        for(int j=k;j<2*k;j++){
            ub2[j]+=b[i][j];
            uw2[j]+=w[i][j];

        }
    }
    for(int i=0;i<=k;i++){
        int p=0;
        for(int j=0;j<k;j++){
            p+=sw[j]+ub[j];
        }
        for(int j=k;j<2*k;j++){
            p+=uw2[j]+sb2[j];
        }
        ans=max(p,ans);
        for(int j=0;j<k;j++){
            p=p-ub[j]-sw[j]+uw[j]+sb[j];
            p=p-uw2[j+k]-sb2[j+k]+ub2[j+k]+sw2[j+k];
            ans=max(ans,p);
        }
        for(int j=0;j<k;j++){
            p=p+ub[j]+sw[j]-uw[j]-sb[j];
            p=p+uw2[j+k]+sb2[j+k]-ub2[j+k]-sw2[j+k];
            ans=max(ans,p);
        }
        for(int j=0;j<k;j++){
            ub[j]-=b[i][j];
            sw[j]+=w[i][j];
            uw[j]-=w[i][j];
            sb[j]+=b[i][j];
        }
        for(int j=k;j<2*k;j++){
            uw2[j]-=w[i][j];
            sb2[j]+=b[i][j];
            ub2[j]-=b[i][j];
            sw2[j]+=w[i][j];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 18688
N = int(input())
A_list = list(map(int, input().split()))
bite = []
for _ in range(60):
    bite.append(0)
    
for A in A_list:
    for i in range(60):
        if A & 1 << i:
            bite[i] += 1

ans = 0
on_right = N - 1
for num in range(len(A_list)):
    A = A_list[num]
    for i in range(60):
        if A & 1 << i:
            bite[i] -= 1
            ans += (on_right - bite[i]) * 1 << i
        else:
            ans += bite[i] * 1 << i
    on_right -= 1

ans %= (10 ** 9 + 7)
print(ans)


Measured memory_bytes: 125624
x1, y1, x2, y2 = map(int, input().split())
v = [x2 - x1, y2 - y1]
w = [y1 - y2, x2 - x1]
print(x1 + v[0] + w[0], y1 + v[1] + w[1], x1 + w[0], y1 + w[1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,m,n) for (int i = m; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n, k;
  cin >> n >> k;
  vector<ll> v(n);
  rep(i,n) cin >> v[i];
  vector<ll> sl(n+1,0), sr(n+1,0);
  rep(i,n) sl[i+1] += sl[i] + v[i];
  rep(i,n) sr[i+1] += sr[i] + v[n-i-1];
  
  ll ans = 0;
  for (int a = 0; a <= min(n, k); ++a) { //左からa個
    priority_queue<ll> que1;
    rep(i,a) que1.push(-v[i]);
    for (int b = 0; b <= min(n-a, k) && a+b <= k; ++b) { //右からb個
      priority_queue<ll> que2 = que1;
      rep(i,b) que2.push(-v[n-i-1]);
      ll sum = sl[a] + sr[b];
      chmax(ans, sum);
      rep(i, k-(a+b)) { //捨てる
        if (que2.empty()) break;
        ll x = que2.top(); que2.pop();
        if (x <= 0) break;
        sum += x;
        chmax(ans, sum);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define INF 1e9
typedef long long ll;
typedef pair<int,int> P;

bool smaller_Se(P& l, P& r){
  if(l.second == r.second) return l.first < r.first;
  return l.second < r.second;
}

int main(void){
  int N,M;cin >> N >> M;
  vector<P> v(M);
  int i;REP(i,M) cin >> v[i].first >> v[i].second;

  sort(v.begin(),v.end(),smaller_Se);
  int pre = 0,count=0;
  //|1|2|3|4|5|
  //0 1 2 3 4 5
  REP(i,M){
    if(v[i].first > pre){
      count++;
      pre = v[i].second-1;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 1024