akhauriyash/Code-Regression huggingface dataset:
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-05-05 16:54:00
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int flag = 0;
  for (auto e : vec) os << (flag++ ? ", " : "{") << e;
  return os << (vec.empty() ? "{}" : "}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int flag = 0;
  for (auto e : st) os << (flag++ ? ", " : "{") << e;
  return os << (st.empty() ? "{}" : "}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int flag = 0;
  for (auto e : mp) os << (flag++ ? ", " : "{") << e;
  return os << (mp.empty() ? "{}" : "}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

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

  int n, q; cin >> n >> q;
  vector<int64> a(n); cin >> a;

  while (q--) {
    int64 x; cin >> x;
    int r = 0;
    int64 sum = 0, ans = 0;

    for (int l = 0; l < n; ++l) {
      while (r < n && sum + a[r] <= x) {
        sum += a[r];
        ++r;
      }
      int len = r - l;
      ans += (int64)(len);
      if (r == l) {
        ++r;
      } else {
        sum -= a[l];
      }
    }
    cout << ans << '\n';
  }

  return 0;
}


Measured memory_bytes: 3516
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <bitset>
#include <sstream>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <climits>
#include <ctype.h>
using namespace std;

#define PI acos(-1.0)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second

#define eps 1e-8
#define mod 998244353

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

struct Matrix {
    vvi data;
    int r, c;
    Matrix(int row, int col, bool identity = false) : r(row), c(col) {
        data.assign(row, vector<int>(col, 0));
        if (identity) {
            for (int i = 0; i < r; ++i) {
                data[i][i] = 1;
            }
        }
    }
    Matrix operator * (Matrix& other) {
        int m = r, n = c, p = other.c;
        Matrix res(m, p);
        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < p; ++j) {
                for (int k = 0; k < n; ++k) {
                    res.data[i][j] += data[i][k] * other.data[k][j];
                }
            }
        }
        return res;
    }
};

// 扩展欧几里得算法 res[1] * a + res[2] * b = res[0] = gcd(a, b)
vector<int> extendGcd(int a, int b) {
    if (b == 0) {
        return {a, 1, 0};
    } else {
        vector<int> tmp = extendGcd(b, a % b);
        return {tmp[0], tmp[2], tmp[1] - (a / b) * tmp[2]};
    }
}

// 矩阵快速幂
Matrix matrix_power(Matrix base, ll exp) {
    int n = base.r;
    Matrix res(n, n, true);
    while (exp) {
        if (exp & 1) {
            res = res * base;
        }
        base = base * base;
        exp >>= 1;
    }
    return res;
}

// 带模快速幂
ll power_mod(ll base, int exp) {
    ll res = 1;
    while (exp) {
        if (exp & 1) res = res * base % mod;
        base = base * base % mod;
        exp >>= 1;
    }
    return res;
}

// 快速幂
ll power(ll base, int exp) {
    ll res = 1;
    while (exp) {
        if (exp & 1) res *= base;
        base *= base;
        exp >>= 1;
    }
    return res;
}

// 求逆元
ll inv(ll a) {
    return power_mod(a, mod - 2);
}

#define MAXFAC 100010

ll fac[MAXFAC];

void initFac() {
    fac[0] = 1;
    for (int i = 1; i < MAXFAC; ++i) {
        fac[i] = i * fac[i - 1] % mod;
    }
}

ll Combine(ll a, ll b) {
    return (fac[a] * inv(fac[b]) % mod) * inv(fac[a - b]) % mod;
}

/******************************** template ********************************/
#define MAXN 100010
int n;

unordered_set<int> ss;

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a;
        scanf("%d", &a);
        if (ss.find(a) != ss.end()) {
            ss.erase(a);
        } else {
            ss.insert(a);
        }
    }
    cout << ss.size();

    return 0;
}

Measured memory_bytes: 4388
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
char str[100100];
int main(){
	scanf("%s",str);
	int len = strlen(str);
	for(int i=0;i<len;i+=2){
		printf("%c",str[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
using namespace std;
int main(){
  vector<lli> a(3);
  rep(i,0,3)cin>>a.at(i);
  rep(i,0,2){
    rep(j,i+1,3){
      if(pow(a.at(i),2)+pow(a.at(j),2)==pow(a.at(3-i-j),2))ou(a.at(i)*a.at(j)/2);
    }
  }
}

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

int main()
{
    int n, k, tmp;
    double res = 0;
    cin >> n >> k;

    vector<double> s(n + 1);
    for(int i = 0; i < n; ++i)
    {
        cin >> tmp;
        double pt = 0;
        for(int j = 1; j <= tmp; ++j)
        {
            pt += double(j * (1 / (double) tmp));
        }
        s[i + 1] = s[i] + pt;
    }

    for(int i = 0; i <= n - k; ++i)
        res = max(s[i + k] - s[i], res);

    cout << setprecision(10) << fixed << res << "\n";
    return 0;
}

Measured memory_bytes: 4844
package main
 
import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)

func main(){
    
    N := nextInt()
    W := nextInt()
    w := make([]int, N)
    v := make([]int, N)
    for i:=0;i<N;i++ {
        w[i] = nextInt()
        v[i] = nextInt()
    }
    
    dp := make([][]int, N)
    for i:=0;i<N;i++ {
        dp[i] = make([]int, W+1)
        for j:=0;j<W+1;j++ {
            dp[i][j] = -1
        }
    }
    dp[0][0] = 0
    dp[0][w[0]] = v[0]
    
    for i:=1;i<N;i++ {
        for j:=0;j<W+1;j++ {
            dp[i][j] = dp[i-1][j]
            if j-w[i]>=0 && dp[i-1][j-w[i]]!=-1 {
                dp[i][j] = Max([]int{dp[i][j], dp[i-1][j-w[i]]+v[i]})
            }
        }
    }
    
    ans := 0
    for i:=0;i<W+1;i++ {
        ans = Max([]int{ans, dp[N-1][i]})
    }
    
	fmt.Println(ans)
}

/* templates */


func Max(a []int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r < a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Min(a []int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r > a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Sum(a []int) (r int) {
    for i := range a {
        r += a[i]
    }
    return r
}
 
func Abs(a int) int {
    if a < 0 {
        return -a
    }
    return a
}
 
type Pair struct {
    a, b int
}
 
type Pairs []Pair
 
func (p Pairs) Len() int {
    return len(p)
}
 
func (p Pairs) Swap(i, j int) {
    p[i], p[j] = p[j], p[i]
}
 
func (p Pairs) Less(i, j int) bool {
    return p[i].b < p[j].b
}
 
var nextReader func() string
 
func init() {
    nextReader = NewScanner()
}
 
func NewScanner() func() string {
    r := bufio.NewScanner(os.Stdin)
    r.Buffer(make([]byte, 1024), int(1e+11))
    r.Split(bufio.ScanWords)
    return func() string {
        r.Scan()
        return r.Text()
    }
}

func nextString() string {
    return nextReader()
}
 
func nextInt64() int64 {
    v, _ := strconv.ParseInt(nextReader(), 10, 64)
    return v
}
 
func nextInt() int {
    v, _ := strconv.Atoi(nextReader())
    return v
}
 
func nextInts(n int) []int {
    r := make([]int, n)
    for i := 0; i < n; i++ {
        r[i] = nextInt()
    }
    return r
}

func nextStrings(n int) []string {
    r := make([]string, n)
    for i := 0; i < n; i++ {
        r[i] = nextString()
    }
    return r
}

func nextFloat64() float64 {
    f, _ := strconv.ParseFloat(nextReader(), 64)
    return f
}


Measured memory_bytes: 81408
/* "It's okay if you hate me. I hate me too." */

#include <bits/stdc++.h>

using namespace std;

const int maxN = (int)1E5+5;
const int MOD = (int)1E9+7;

int a[maxN];
int d[maxN];
int product[maxN], fact[maxN];
int comb_N[maxN], comb_M[maxN];
int rep_val;
int low, high;
int n, m;

int powMOD(int A, int M) {
	if (M == 0) return 1;
	int T = powMOD(A, M/2);
	T = ((long long)T*T)%MOD;
	if (M&1) T = ((long long)T*A)%MOD;
	return T;
}

void precalculate(int N, int comb[]) {
	fact[0] = 1;
	for (int i = 1; i <= N; ++i)
		fact[i] = ((long long)fact[i-1]*i)%MOD;
	product[N+1] = 1;
	for (int i = N; i >= 1; --i)
		product[i] = ((long long)product[i+1]*i)%MOD;
	for (int i = 1; i <= N; ++i)
		comb[i] = ((long long)product[N-i+1]*powMOD(fact[i], MOD-2))%MOD;
	comb[0] = comb[N];
}

int Comb_N(int K) { 	// N = n+1
	if (K < 0 || K > n+1) return 0;
	return comb_N[K]; 
}

int Comb_M(int K) { 	// M = m
	if (K < 0 || K > m) return 0;
	return comb_M[K]; 
}

int main() {
	scanf("%d", &n);
	memset(d+1, 0, sizeof(int)*n);
	for (int i = 1; i <= n+1; ++i) {
		scanf("%d", &a[i]);
		++d[a[i]];
	}

	for (int i = 1; i <= n; ++i)
		if (d[a[i]] > 1) {	// d[a[i]] == 2
			rep_val = a[i];
			break;
		}
	
	for (int i = 1; i <= n+1; ++i)
		if (a[i] == rep_val) {
			low = i;
			break;
		}
	for (int i = n+1; i >= 1; --i)
		if (a[i] == rep_val) {
			high = i;
			break;
		}
	
	m = n+1-(high-low+1);
	
	precalculate(n+1, comb_N);
	precalculate(m, comb_M);
	printf("%d\n", n);
	for (int i = 2; i <= n+1; ++i) {
		printf("%d\n", ((Comb_N(i)-Comb_M(i-1)+MOD)%MOD));
	}
	return 0;
}


Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        int h = s / 60 / 60;
        int m = (s - h * 60 * 60) / 60;
        s = s % 60;

        System.out.println(h + ":" + m + ":" + s);
    }
}


Measured memory_bytes: 26344
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#define N 1000010
#define ls x << 1
#define rs x << 1 | 1
#define inf 0x3f3f3f3f
#define inc(i) (++ (i))
#define dec(i) (-- (i))
#define mid ((l + r) >> 1)
#define int long long
#define XRZ 1000000007
#define debug() puts("XRZ TXDY");
#define mem(i, x) memset(i, x, sizeof(i));
#define Next(i, u) for(register int i = head[u]; i ; i = e[i].nxt)
#define file(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout);
#define Rep(i, a, b) for(register int i = (a) , i##Limit = (b) ; i <= i##Limit ; inc(i))
#define Dep(i, a, b) for(register int i = (a) , i##Limit = (b) ; i >= i##Limit ; dec(i))
int dx[10] = {1, -1, 0, 0};
int dy[10] = {0, 0, 1, -1};
using namespace std;
inline int read() {
    register int x = 0, f = 1; register char c = getchar(   );
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
    return x * f;
}

double a, b, c; int n;
signed main() { n = read();
	a = b = c = 1.0 * n / 3;
	printf("%.10f\n", a * b * c);
	return 0;
}

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

int main(void) {
  int i, a = -1;
  bool flg[26];
  for(i = 0; i < 26; ++i) flg[i] = true;
  char s[110000];
  scanf("%s", s);
  for(i = 0; i < strlen(s); ++i) flg[s[i] - 'a'] = false;
  for(i = 25; i >= 0; --i) if(flg[i]) a = i;
  if(a == -1) printf("None");
  else printf("%c", a + 'a');
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main()
{
    int h;
    cin >> h;
    int w;
    cin >> w;
    vector<string> a(h);
    for (int i = 0; i < h; i++)
    {
        cin >> a[i];
    }

    vector<bool> row(h, false);
    vector<bool> col(w, false);
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (a[i][j] == '#')
            {
                row[i] = true;
                col[j] = true;
            }
        }
    }

    for (int i = 0; i < h; i++)
    {
        if (row[i])
        {
            for (int j = 0; j < w; j++)
            {
                if (col[j])
                {
                    cout << a[i][j];
                }
            }
            cout << endl;
        }
    }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program {
    static void Main( string[] args )
    {
        string[] suit = new string[ 4 ] { "S ", "H ", "C ", "D " };

        List<string> deck = new List<string>( 52 );

        for ( int i = 0; i < 4; ++i ) {
            for ( int j = 1; j < 14; ++j ) {
                deck.Add( suit[ i ] + j );
            }
        }

        int n = int.Parse( Console.ReadLine() );

        for ( int i = 0; i < n; ++i ) {
            deck.Remove( Console.ReadLine() );
        }

        for ( int i = 0; i < deck.Count; ++i ) {
            Console.WriteLine( deck[ i ] );
        }
    }
}

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

using namespace std;

int main() {
    int n, d, x;

    cin>>n>>d>>x;
    int a[n];
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=(d-1)/a[i]+1;
    }
 
     sum+=x;

    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>

using namespace std;

#define N 10010
typedef long long ll;
ll p[N],q[N];
class RollingHash2{
private:
  ll aa[N];
  ll bb[N];
  ll P,Q;
public:
  RollingHash2(){}
  RollingHash2(string &s,ll _P,ll _Q){
    int n=s.size();
    aa[0]=bb[0]=0;
    P=_P;
    Q=_Q;
    // hash値を計算
    for(int i=1;i<=n;i++)aa[i]=aa[i-1]*P+s[i-1];
    for(int i=1;i<=n;i++)bb[i]=bb[i-1]*Q+s[i-1];
  }
  pair<ll,ll> getHash(int x,int y){
    return make_pair(aa[y+1]-aa[x]*p[y-x+1],
		     bb[y+1]-bb[x]*q[y-x+1]);
  }
};
RollingHash2 fHash;

// 格文字列のハッシュ値
pair<ll,ll> hashVal[12];
ll dp[1<<12][12];
string strs[12];
string fullTxt;
int n,m;
ll dfs(int pos,int mask,int cur){
  if(dp[mask][cur]>=0)return dp[mask][cur];
  else if(mask==(1<<n)-1)return 1;
  ll res=0;
  for(int i=0;i<n;i++){
    if((mask>>i)&1)continue;
    // ハッシュ値が一致する場合
    if(fHash.getHash(pos,pos+strs[i].size()-1)
       ==hashVal[i]){
      res+=dfs(pos+strs[i].size(),mask|(1<<i),i);
    }
  }
  return dp[mask][cur]=res;
}

ll fact[20];
int main(){
  const ll P=1000000007;
  const ll Q=4300003200017LL;
  fact[0]=1;
  for(int i=1;i<20;i++)fact[i]=fact[i-1]*i;
  // P**iを計算
  p[0]=1;
  for(int i=1;i<=10000;i++)p[i]=p[i-1]*P;
  q[0]=1;
  for(int i=1;i<=10000;i++)q[i]=q[i-1]*Q;
  while(cin>>n>>m&&(n|m)){
    fullTxt="";
    int sz=0;
    map<string,int> scnt;
    for(int i=0;i<n;i++){
      cin>>strs[i];
      scnt[strs[i]]++;
      sz+=strs[i].size();
      // ハッシュ値を計算しておく
      RollingHash2 rh(strs[i],P,Q);
      hashVal[i]=rh.getHash(0,strs[i].size()-1);
    }
    ll divNum=1;
    for(map<string,int>::iterator it=scnt.begin();
	it!=scnt.end();it++){
      divNum*=fact[it->second];
    }
    for(int i=0;i<m;i++){
      string tmp;cin>>tmp;
      fullTxt+=tmp;
    }
    // 計算済みの結果を登録しておく
    map<pair<ll,ll>,ll> mem;
    fHash=RollingHash2(fullTxt,P,Q);
    ll res=0;
    for(int i=0;i+sz<=fullTxt.size();i++){
      pair<ll,ll> hv=fHash.getHash(i,i+sz-1);
      // 計算済みであれば
      if(mem.find(hv)!=mem.end())res+=mem[hv];
      // まだ計算済みでない
      else{
	memset(dp,-1,sizeof(dp));
	ll tmp=0;
	for(int j=0;j<n;j++){
	  if(fHash.getHash(i,i+strs[j].size()-1)
	     ==hashVal[j])
	    tmp+=dfs(i+strs[j].size(),1<<j,j);
	  if(tmp>0){
	    tmp=1;
	    break;
	  }
	}
	mem[hv]=tmp;
	res+=tmp;
      }
    }
    cout<<res<<endl;
  }
  return 0;
}

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

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

    vector<int> monsterVec;
    for (int i = 0; i < n + 1; ++i)
    {
        int input;
        cin >> input;
        monsterVec.push_back(input);
    }

    long long beatenCount = 0;
    for (int i = 0; i < n; ++i)
    {
        int remainPower;
        cin >> remainPower;

        if (monsterVec.at(i) > remainPower)
        {
            beatenCount += remainPower;
            remainPower = 0;
        }
        else
        {
            beatenCount += monsterVec.at(i);
            remainPower -= monsterVec.at(i);
        }

        if (monsterVec.at(i + 1) > remainPower)
        {
            beatenCount += remainPower;
            monsterVec.at(i + 1) -= remainPower;
        }
        else
        {
            beatenCount += monsterVec.at(i + 1);
            monsterVec.at(i + 1) = 0;
        }
    }

    cout << beatenCount << endl;
}

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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    string s1, s2, s3;
    cin >> s1 >> s2;

    // 処理
    s3 = s1 + s1;

    regex  re(s2, regex_constants::icase);
    smatch m;

    // 出力
    cout << (regex_search(s3, m, re) ? "Yes" : "No") << endl;

    // 見つかった文字列
    // cout << m.str() << endl;

    return 0;
}


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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#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__)
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  each(x,vec) is >> x;
  return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
  rep(i,vec.size()) {
    if (i) os << " ";
    os << vec[i];
  }
  return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
  rep(i,vec.size()) {
    if (i) os << endl;
    os << vec[i];
  }
  return os;
}
ll f(ll n) {
  return n * (n-1) * (n-2) + n * (n-1) * 3 + n;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, K; cin >> n >> K;
  vector<ll> cnt(K);
  rep(i, 1, n+1) {
    cnt[i % K]++;
  }
  ll ans = f(cnt[0]);
  if (K % 2 == 0) {
    ll k = K/2;
    ans += f(cnt[k]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int main() {
	int n, m; cin >> n >> m;
	int ng[100100] = {};
	for (int i = 0; i < m; i++)
	{
		int a; cin >> a;
		ng[a] = 1;
	}

	int res[100100];
	if(ng[1]) {
		res[1] = 0;
		if(ng[2]) res[2] = 0;
		else res[2] = 1;
	}
	else {
		res[1] = 1;
		if(ng[2]) res[2] = 0;
		else res[2] = 2;
	}

	for (int i = 3; i <= n; i++)
	{
		if(ng[i]) res[i] = 0;
		else res[i] = (res[i-1] + res[i-2]) % MOD;
	}
	cout << res[n] << endl;
	return 0;
}


Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
const int INF = 1e9;

int main() {
  int r;
  cin >> r;
  cout << r * r << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

inline int min(int a, int b) {
    return a<b? a: b;
}

int main() {
    int R, G, B, N, r,g,b, i;
    char buf[20];
    while (scanf("%d", &N) != EOF) {
        int type1 = 0, type2 = 0, cnt = 0, both = 0;// type1 = ***A, type2 = B***
        while (N--) {
            scanf("%s", buf);
            for (i = 1; buf[i] != '\0'; i++) {
                if (buf[i] == 'B' && buf[i-1] == 'A')
                    cnt++;
            }
            if (buf[i-1] == 'A' && buf[0] == 'B') {//分别计算
                both++;
            }
            else if (buf[i-1] == 'A') {
                type1++;
            }
            else if (buf[0] == 'B') {
                type2++;
            }
            
        }
       ;// both > 0
        if (both > 0) {
             cnt += both-1;
             if (type1 > 0)
                cnt++, type1--;
            if (type2 > 0)
                cnt++, type2--;
            cnt += min(type1, type2);
        } else {
             cnt += min(type1, type2);
        }
        printf("%d\n", cnt);
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
using namespace std;

int main(){
    int N,M;
    char n[50][51],m[50][51];
    bool flag;
    cin >> N >> M;
    for(int i=0;i<N;i++)    cin >> n[i];
    for(int i=0;i<M;i++)    cin >> m[i]; 
    if(M>N) cout << "No\n";
    else{
        for(int y=0;y<=N-M;y++){
            for(int x=0;x<=N-M;x++){
                flag = true;
                for(int i=0;i<M;i++){
                    for(int j=0;j<M;j++){
                        if(n[y+i][x+j]!=m[i][j]){
                            flag = false;
                            break;
                        }
                    }
                    if(!flag)   break;
                }
                if(flag){
                    cout << "Yes\n";
                    return 0;
                }
            }
        }
    }
    cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  B - Iron Bar Cutting
//
//  Created by Hashizo on 2019/11/23.
//  Copyright © 2019 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#include <cmath>

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())

int main(int argc, const char * argv[]) {
	ll ans = LONG_MAX;
	ll diff = 0;
	ll total = 0;
	ll ave = 0;
	ll left = 0;
	ll right = 0;
	ll harf = 0;
	ll shift = 0;
	
	ll n;
	cin >> n;

	vector<ll> iron(n);
	REP(i, n) {
		cin >> iron[i];
		total += iron[i];
	}

	ave = total / 2;

	harf = n / 2;

	
	REP(i, harf) {
		left += iron[i];
	}
	
	FOR(i, harf, n) {
		right += iron[i];
	}
	ans = abs(left - ave) + abs(right - ave);

	
	REP(i, n) {
		left = 0;
		right = 0;

		shift = harf - (i+1);
	
		REP(i, shift) {
			left += iron[i];
		}
		
		FOR(i, shift, n) {
			right += iron[i];
		}

		
		diff = abs(left - ave) + abs(right - ave);
		if (ans > diff) {
			ans = diff;
		}
		else {
			break;
		}
	}

	REP(i, n) {
		left = 0;
		right = 0;

		shift = harf + (i+1);
	
		REP(i, shift) {
			left += iron[i];
		}
		
		FOR(i, shift, n) {
			right += iron[i];
		}

		
		diff = abs(left - ave) + abs(right - ave);
		if (ans > diff) {
			ans = diff;
		}
		else {
			break;
		}
	}

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


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,zs[500009],zh[2000009],lf,rg,i,j,mn,p[1000009],pi,dp[1000009],ind[1000009];
deque <int> de;
string s,h,hh,hhh;
vector <int> v[1000009];
int bo[1000009];
void dfs(int q){
	bo[q]=i+1;
	pi++;
	p[pi]=q;
	for(vector <int>::iterator it=v[q].begin(); it!=v[q].end(); it++){
		if(bo[(*it)]==i+1){
			cout<<-1;
			exit(0);
		}
		if(bo[(*it)]==0){
			dfs((*it));
		}
	}
}
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>hhh>>s;
	while(hh.size()<s.size()) hh.insert(hh.size(),hhh);
	h=hh+hh;
	a=s.size()-1;
	b=h.size()-1;
	zs[0]=0;
	lf=0;rg=0;
	for(i=1; i<=a; i++){
		if(rg<i){
			c=i;
			while(c<=a&&s[c]==s[c-i]) c++;
			c--;zs[i]=c-i+1;
			if(rg<c){
				lf=i;rg=c;
			}
		}else{
			mn=rg-i+1;
			if(mn>zs[i-lf]) mn=zs[i-lf];
			c=i+mn-1;if(c<i) c=i;
			while(c<=a&&s[c]==s[c-i]) c++;
			c--;zs[i]=c-i+1;
			if(rg<c){
				lf=i;rg=c;
			}
		}
	}
	lf=-1;rg=-1;
	for(i=0; i<=b; i++){
		if(rg<i){
			c=i;
			while(c<=b&&c-i<=a&&h[c]==s[c-i]) c++;
			c--;zh[i]=c-i+1;
			if(rg<c){
				lf=i;rg=c;
			}
		}else{
			mn=rg-i+1;
			if(mn>zs[i-lf]) mn=zs[i-lf];
			c=i+mn-1;if(c<i) c=i;
			while(c<=b&&c-i<=a&&h[c]==s[c-i]) c++;
			c--;zh[i]=c-i+1;
			if(rg<c){
				lf=i;rg=c;
			}
		}
	}
	b=hh.size()-1;
	for(i=0; i<=b; i++){
		if(zh[i]==a+1){
			c=i+a+1;
			if(c>b) c-=b+1;
			if(zh[c]==a+1){
				v[i].push_back(c);
//				cout<<i<<" to "<<c<<endl;
			}
		}
	}
	for(i=0; i<=b+2; i++){
		if(bo[i]!=0) continue;
		pi=0;
		dfs(i);
		for(j=pi; j>=1; j--){
			de.push_front(p[j]);
		}
	}
//	for(i=0; i<de.size(); i++) ind[de[i]]=i;
	c=0;
	for(i=de.size()-1; i>=0; i--){
		int q=de[i];
		for(vector <int>::iterator it=v[q].begin(); it!=v[q].end(); it++){
			if(dp[q]<dp[(*it)]+1) dp[q]=dp[(*it)]+1;
		}
		if(dp[q]==0&&zh[q]==a+1) dp[q]=1;
		if(c<dp[q]) c=dp[q];
	}
	cout<<c;
	return 0;
}

Measured memory_bytes: 93724
/*input
3 998244353
*/
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout << "[" << #__VA_ARGS__ << ": " << __VA_ARGS__ << "]\n"
#define rd() abs((int)rng())
using namespace std;
typedef long long ll;
typedef double ld;
typedef pair<int, int>pii;
const int maxn = 5050;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int n, k, MOD, change[maxn];
void add(int &a, int b)
{
	a += b;
	if(a >= MOD)
		a -= MOD;
}
int dp[maxn][maxn];
int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0);
	cin >> n >> MOD;
	
	k = (n - 1) / 2;
	change[0] = 0;
	for(int i = 1; i <= k; i++)
		change[i] = -i;
	if(n % 2 == 0)
		change[k + 1] = -k;
	int cur = -k;
	for(int i = k + (n % 2 == 0) + 1; i <= n; i++)
	{
		++cur;
		change[i] = cur;
	}

	sort(change, change + n + 1);

	for(int i = 0; i <= n - 1; i++)
		dp[0][i] = 1;

	int ans = 0;
	for(int i = 0; i < n - 2; i++)
	{
		for(int opsbal = 0; opsbal <= n; opsbal++)
		{
			if(opsbal - change[i] + 1 <= n)
				add(dp[i][opsbal - change[i] + 1], dp[i][opsbal]);
			add(dp[i + 1][opsbal], dp[i][opsbal]);
		}
	}
	for(int opsbal = 0; opsbal <= n; opsbal++)
		add(ans, 1ll * dp[n - 2][opsbal] * (n - opsbal) % MOD);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 98944
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
	int R[MAX], n;
	 cin >> n;
	for(int i=0;i<n;i++) cin >> R[i];
	
	int maxv = -2000000000;
	int minv = R[0];
	
	for(int i=1;i<n;i++){
		maxv = max(maxv, R[i]-minv);
		minv = min(minv, R[i]);
	}
	
	cout << maxv << endl;
	
	return 0;
}

Measured memory_bytes: 3860
using System;

namespace _1137
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                string[] s = Console.ReadLine().Split();
                int ret = 0; int times = 1;
                for (int j = 0; j < s[0].Length; j++)
                {
                    switch (s[0][j])
                    {
                        case ('m'): { ret += 1000 * times; times = 1; break; }
                        case ('c'): { ret += 100 * times; times = 1; break; }
                        case ('x'): { ret += 10 * times; times = 1; break; }
                        case ('i'): { ret += 1 * times; times = 1; break; }
                        default:
                        {
                            times = int.Parse(s[0][j].ToString());
                            break;
                        }
                    }
                }
                for (int j = 0; j < s[1].Length; j++)
                {
                    switch (s[1][j])
                    {
                        case ('m'): { ret += 1000 * times; times = 1; break; }
                        case ('c'): { ret += 100 * times; times = 1; break; }
                        case ('x'): { ret += 10 * times; times = 1; break; }
                        case ('i'): { ret += 1 * times; times = 1; break; }
                        default:
                        {
                            times = int.Parse(s[1][j].ToString());
                            break;
                        }
                    }
                }
                if (ret >= 2000) Console.Write(ret / 1000);
                if (ret >= 1000) Console.Write("m");
                ret %= 1000;
                if (ret >= 200) Console.Write(ret / 100);
                if (ret >= 100) Console.Write("c");
                ret %= 100;
                if (ret >= 20) Console.Write(ret / 10);
                if (ret >= 10) Console.Write("x");
                ret %= 10;
                if (ret >= 2) Console.Write(ret / 1);
                if (ret >= 1) Console.Write("i");
                Console.WriteLine();
            }
        }
    }
}


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

using namespace std;

int main()
{
  int N, T, E;
  int x;
  vector<int> vec_x;

  cin >> N >> T >> E;

  while (N--) {
    cin >> x;
    vec_x.push_back(x);
  }

  int i;
  bool isAldente = false;
  for (i = 0; i != vec_x.size(); i++) {
    for (int j = T - E; j <= T + E; j++) {
      if (!(j % vec_x.at(i))) {
        isAldente = true;
        break;
      }
    }
    if (isAldente) break;
  }

  isAldente ? cout << i + 1 << endl : cout << "-1" << endl;
}



Measured memory_bytes: 3156
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
// #define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    // init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    int l=0,r=n-1;
    string ls,rs;
    cout<<l<<endl;
    cin>>ls;
    if(ls=="Vacant")return;
    cout<<r<<endl;
    cin>>rs;
    if(rs=="Vacant")return;
    while(true){
        int m=(l+r)/2;
        cout<<m<<endl;
        string s;
        cin>>s;
        if(s=="Vacant")return;
        if(s==ls&&(m-l)%2){
            r=m;
            rs=s;
        }
        else if(s!=rs&&(r-m)%2==0){
            l=m;
            ls=s;
        }
        else if(s==rs&&(r-m)%2){
            l=m;
            ls=s;
        }
        else {
            r=m;
            rs=s;
        }
    }
}

Measured memory_bytes: 852
import java.util.*;
public class Main{   
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int m1 = sc.nextInt();
      int d1 = sc.nextInt();
      int m2 = sc.nextInt();
      int d2 = sc.nextInt();
      if(d2==1)System.out.println(1);
      else System.out.println(0);
    }
    public static int lcm(int x, int y){
      return x*y/gcd(x,y);
    }
    public static int gcd(int x, int y){
      if(x < y)return gcd(y,x);
      if(y==0)return x;
      return gcd(y,x%y);
    }
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<long long> p(N);
    for(int i = 0; i < N; ++i)
        cin >> p[i], ++p[i]; // 1 足しておく

    // 累積和
    vector<long long> s(N + 1, 0);
    for(int i = 0; i < N; ++i)
        s[i + 1] = s[i] + p[i];

    // K 差を見ていく
    long long res = 0;
    for(int i = 0; i + K <= N; ++i)
        res = max(res, s[i + K] - s[i]);
    cout << fixed << setprecision(10) << (double)(res) / 2 << endl;
}

Measured memory_bytes: 6380
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
int main()
{
    int n;
    cin>>n;
    vector<int> b(n-1);
    rep(i,n-1) cin>>b[i];

    ll ans=0;
    vector<int> a(n);
    a[0]=b[0];
    a[n-1]=b[b.size()-1];
    for (int i = 1; i <= b.size()-1; i++)
    {
        a[i]=min(b[i],b[i-1]);
    }
    ans=accumulate(a.begin(),a.end(),0);
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;



int main()
{
  for(int i = 0; i < 5; i++) {
    int a; cin >> a;
    if(!a) cout << i + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <limits>
#include <algorithm>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(true) {
        int h, w;
        cin>>h>>w;
        if(h==0 && w==0) break;
        for(int i=0; i<h; i++) {
            for(int j=0; j<w; j++) {
                cout<<'#';
            }
            cout<<'\n';
        }
        cout<<'\n';
    }
    return 0;
}

Measured memory_bytes: 1176
#include<stdio.h>

int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    int d,r;
    double f;
    d=a/b;
    r=a%b;
    f=a*1.0/b;
    printf("%d %d %.5f\n",d,r,f);
    return 0;
}



Measured memory_bytes: 2096
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define ep emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007, MAX = 100005;

vector<bool> sieve(int n)
{
  vector<bool> prime(n+1, true);
  prime[0] = prime[1] = false;

  for (int i = 2; i <= n; ++i) {
    if (!prime[i]) continue;

    for (int j = 2; i * j <= n; ++j) prime[i * j] = false;
  }

  return prime;
}

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  int x; cin >> x;
  auto p = sieve(MAX);

  while (!p[x]) ++x;
  cout << x << endl;

  return (0);
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second 
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
//#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
inline void out(int x){
	if(x>=10)out(x/10);
	putchar(x%10+'0');
}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	double x=100;
	ll k;
	cin>>k;
	int ans=0;
	while(x<k){
		x=floor(x*(double)1.01);
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>
void CountingSort(int *,int *,int);
int C[10001]={0};
int main(void){
  int n,*A,*B,i;
  scanf("%d",&n);
  A=(int *)malloc(sizeof(int)*n);
  B=(int *)malloc(sizeof(int)*n);
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);
  
  CountingSort(A,B,n);
  for(i=0;i<n;i++){
    printf("%d",B[i]);
    if(i!=n-1)printf(" ");
  }
  printf("\n");
  return 0;
}
void CountingSort(int *A,int *B,int k){
  int i;
  /* C[i] に i の出現数を記録する */
  for(i=0;i<k;i++)
    C[A[i]]++;

  /* C[i] に i 以下の数の出現数を記録する*/
  i=0;
  while(i<10001){
    C[i]=C[i]+C[i-1];
    i++;
  }

  for(i=k-1;i>=0;i--){
    B[C[A[i]]-1]=A[i];
    C[A[i]]--;
  }
}


Measured memory_bytes: 17436
#include <bits/stdc++.h>
using namespace std ;
typedef long long ll;

int main(){
    int n;cin>>n;
    int keta=log10(n);
    int count =0;
    for(int i=1;i<=keta+1;i++){
        if(i%2==1){
            if(i==keta+1) count+=n-pow(10,keta)+1;
            else count += pow(10,i)-pow(10,i-1);

        }

    }
    cout << count;
    
}

Measured memory_bytes: 3996
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<long double,long double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-10;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int a,b;

int main(){
	cin>>a>>b;
	if(a*b%2==0) cout<<"Even"<<endl;
	else cout<<"Odd"<<endl;
}

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

ll n, x[370], y[370], b[370], p[370], s1, s2;




int main(){

	cin >> n;
	for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> b[i] >> p[i];

	for (int i = 0; i < n; i++){
		s1 = x[i] * b[i] + y[i] * p[i];
		if (b[i] < 5) b[i] = 5;
		if (p[i] < 2) p[i] = 2;
		s2 = (x[i] * b[i] + y[i] * p[i]) * (1 - 0.2);
		
		cout << min(s1, s2) << endl;
	}





	return 0;
}


Measured memory_bytes: 3124
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;
 vector<pair<int,int>>task;

int main()
{
    int N;
    cin>>N;
    for(int i=0;i<N;i++){
        int A,B;
        cin>>A>>B;
        task.emplace_back(B,A);
    }
    sort(task.begin(),task.end());
     for(int i=0;i<N;i++){
    }
    int sum=0;
    string ans="Yes";
    for(auto a:task){
        sum+=a.second;
        if(sum>a.first){
            ans="No";
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2420
#include <iostream>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) scanf("%d", &v)

int main() {
  int N, M, K;
  IN(N); IN(M); IN(K);

  REP(n, N+1) REP(m, M+1) {
    if (n*M + N * m - 2 * n * m == K) {
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");

  return 0;
}


Measured memory_bytes: 256
import math

n,m=map(int,input().split())

dog = math.factorial(n)%(10**9+7)
monkey = math.factorial(m)%(10**9+7)

if abs(n-m)>1:
  print(0)
elif n==m:
  print(2*dog*monkey%(10**9+7))
else:
  print(dog*monkey%(10**9+7))

Measured memory_bytes: 4152
import collections

N, K = map(int, input().split())
R, S, P = map(int, input().split())
information = list(input())

convert_information=information[:K]
CNT_information = collections.Counter(information[:K])

rock = R * CNT_information['s']
sciss = S * CNT_information['p']
par = P * CNT_information['r']

total = rock + sciss + par

for i in range(N - K):
    index = i + K
    point = 0
    
    if (convert_information[i] == information[index]):
        convert_information.append('x')
    
    else:
        hand = information[index]

        if (hand == 's'):
            point = R
            convert_information.append('s')

        elif (hand == 'p'):
            point = S
            convert_information.append('p')

        else:
            point = P
            convert_information.append('r')
    
    total += point


print(total)


Measured memory_bytes: 5540
from itertools import permutations
import math
menu=5
ABCDE=[int(input()) for i in range(menu)]
orders=list(permutations(ABCDE,menu))
minimum=sum(math.ceil(time/10)*10 for time in ABCDE)
for order in orders:
    total=order[0]
    for i in range(1,menu):
        total+=math.ceil(order[i]/10)*10
    minimum=min(minimum,total)
print(minimum)

Measured memory_bytes: 9188
package main
import (
  "fmt"
)
func main() {
  var d, g int
  fmt.Scan(&d, &g)
  ps := make([]int, d)
  cs := make([]int, d)
  for i := 0; i < d; i++ {
    fmt.Scan(&ps[i], &cs[i])
  }
  result := 1000
  for i := 0; i < 1<<uint(d); i++ {
    solvedCnt := 0
    score := 0
    maxNotSolvedIndex := 10
    for j := 0; j < d; j++ {
      isAllSolved := i>>uint(j)&1 == 1
      if !isAllSolved {
        maxNotSolvedIndex = j
        continue
      }
      solvedCnt += ps[j]
      score += 100*(j+1)*ps[j] + cs[j]
    }
    if g <= score {
      if solvedCnt < result {
        result = solvedCnt
      }
      continue
    }
    if maxNotSolvedIndex == 10 {
      continue
    }
    for k := 1; k < ps[maxNotSolvedIndex]; k++ {
      score += 100*(maxNotSolvedIndex+1)
      solvedCnt++
      if g <= score {
        if solvedCnt < result {
          result = solvedCnt
        }
        break
      }
    }
  }
  fmt.Println(result)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <vector>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, a, b) for(ll i = ll(a); i <= ll(b); i++)
int main()
{
	ll n,m;ld x,y,sum=0.0;
	cin>>n;
	vector<ll> a;

	rep(i,0,n-1)
	{
		cin>>m;
		a.push_back(m);
	}

	sort(a.begin(),a.end());

	x=(a[0]+a[1])/2.0;

	rep(i,2,n-1)
		x=(x+a[i])/2.0;
	cout<<x;

	return 0;
}

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

int main(){
    double n,k;
    cin >> n >> k;
    vector<int> t(n);
    int c = 0;

    for (int i = n; i >= 1; i--){
        int s = i;
        while (s * pow(2, c) < k){
            c++;
        }
        t[i-1] = c;
    }

    double ans = 0;
    if (k != 1){
        for (int i = 0; i < n; i++){
            ans += 1/n * pow(0.5, t[i]);
        }
        cout << fixed << setprecision(12);
        cout << ans << endl;
    }
    else{
        cout << 1 << endl;
    }
    
}

Measured memory_bytes: 4236
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
    string a;
    string b;
    string c;
    
    cin>>a;
    cin>>b;
    cin>>c;

    cout<<a[0]<<b[1]<<c[2]<<endl;

    return 0;
}

Measured memory_bytes: 256