akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int gcd(int a, int b) {
	int result = a;
	int k = 0;
	int n = b;
	do {
		k = result % n;
		result = n;
		n = k;
	} while(k != 0);
	return result;
}

int main(){
    int n;
    cin >> n;
    vector<int> arr(n);
    rep(i,n) cin >> arr[i];
    int ans = gcd(arr[0],arr[1]);

    reps(i,1,n-1){
        ans = gcd(ans,arr[i+1]);
    }
    cout << ans << endl;

    return 0;
}

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

string s;
int a,b;

int main(){
	cin>>s;
	for(int i = 1; i < s.length(); i++){
		if(s[i]=='B' && s[i-1] == 'W') a++;
		if(s[i] == 'W' && s[i-1] == 'B') b++;
	}
	int Max = max(a, b);
	if( (a + b) % 2 == 0) cout << Max * 2 << endl;
	else cout << Max * 2 - 1 << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i,m,n) for(int i = m;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
int main() {
  lli A,B,C=1,D=0,E=0,F=0,G=0,H=0,N,M;
  cin >> N >> A;
  rep(i,0,N-1)C*=(A-1);
  Out(C*A);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define hetu int t;cin >> t;while(t--) 

void solve()
{
    ll n;
    cin >> n;
    ll a[n];
    for(ll i=0;i<n;++i)
    cin >> a[i];
    ll ans=0;
    for(ll i=0;i<n-1;++i)
    {
        if(a[i+1]<a[i])
        {
            ans+=abs(a[i]-a[i+1]);
            a[i+1]=a[i];
        }
    }
    cout << ans << endl;

}
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    //hetu
    solve();
    return 0;
}

Measured memory_bytes: 5192
n, k = map(int, input().split())
x = list(map(int, input().split()))

ans = pow(10, 9)
for i in range(n - k + 1):
    tmp = min(abs(x[i]), abs(x[i + k - 1]))
    ans = min(ans, tmp + x[i + k - 1] - x[i])
print(ans)


Measured memory_bytes: 84756
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <bits/stdc++.h>
#define re register
using namespace std;
typedef long long ll;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=200000+10;

int n,a[N];
int L[N],R[N];
int sta[N],top=0;

int main() {
    n=read();
    for (re int i=1;i<=n;++i) a[i]=read();
    a[0]=0,sta[top=1]=0;
    for (re int i=1;i<=n;++i) {
        while (top&&a[i]<a[sta[top]]) --top;
        L[i]=sta[top],sta[++top]=i;
    }
    a[n+1]=0,sta[top=1]=n+1;
    for (re int i=n;i;--i) {
        while (top&&a[i]<a[sta[top]]) --top;
        R[i]=sta[top],sta[++top]=i;
    }
    ll ans=0;
    for (re int i=1;i<=n;++i) ans+=1ll*a[i]*(i-L[i])*(R[i]-i);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
long X;
bool dp[1<<17];
int main(){
  cin>>X;
  for(int i=100;i<106;i++)dp[i]=true;
  for(int i=100;i<=1e5;i++)if(dp[i])for(int j=0;j<6;j++)dp[i+100+j]=dp[i];
  cout<<dp[X]<<endl;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> A;
    for(int i = 0; i < N; i++){
        int a;
        cin >> a;
        A.push_back(a);
    }
    int ans = 0;
    bool finish = false;
    for(int i = 0; true; i++){
        for(int j = 0; j < N; j++){
            if(A.at(j) % 2 == 1){
                finish = true;
                break;
            }
            else A.at(j) = A.at(j) / 2;
        }
        if(finish == true) break;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include <stdio.h>
int main(void)
{
  int n, i, min, max, a[10000];
  double sum;

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  min = a[0];
  max = a[0];
  sum = a[0];
  for (i = 1; i < n; i++) {
    if (min > a[i]) min = a[i];
    if (max < a[i]) max = a[i];
    sum += a[i];
  }
  printf("%d %d %.0lf\n", min, max, sum);
  return 0;
}

Measured memory_bytes: 672
#include<iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include<unordered_map>
using namespace std;
const long long int mod1=1000000007;
const long long int mod2 = -1;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pp pop_back                                       
#define ff first
#define ss second
#define ll long long int
#define ull unsigned long long int
#define ordered_set tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define ordered1 tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define inf mod1
#define all(x) x.begin(),x.end()
ll gcd(ll a, ll b){
    ll c;
     while(b){
        c = b;
        b = a % b;
        a = c;
     }
     return a;
}
ll power1(ll a, ll b){
     if(b == 0) return 1;
     else if(b % 2) return a * power1(a, b - 1);
     else {
        ll temp = power1(a, b / 2);
        return temp * temp;
     }
}
ll power2(ll a, ll b, ll m){
     a %= m;
     if(b == 0) return 1;
     else if(b % 2) return (a * power2(a, b - 1, m)) % m;
     else{
        ll temp = power2(a, b / 2, m);
        return (temp * temp) % m;
     }
}
ll mod(ll x, ll p){
return (x % p + p) % p;
}
ll lcm(ll x, ll y){
return (x * y)/gcd(x, y);
}
int main(){
    fast;
    ll tt = 1;
    //cin >> tt;
    while(tt--){
      ll n, k;
      cin >> n >> k;
      ll cnt[n] = {};
      while(k--){
        ll d;
        cin >> d;
        while(d--){
            ll x;
            cin >> x;
            cnt[x - 1]++;
        }
      }
      ll o = 0;
      for(int i = 0; i < n; i++){
        if(cnt[i] == 0){o++;}
      }
      cout << o << endl;
    }
}

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

using namespace std;

int main() {
	string S;
	int i;
	cin >> S;
	if (S == "SUN") {
		i = 0;
	} else if (S == "MON") {
		i = 1;
	} else if (S == "TUE") {
		i = 2;
	} else if (S == "WED") {
		i = 3;
	} else if (S == "THU") {
		i = 4;
	} else if (S == "FRI") {
		i = 5;
	} else if (S == "SAT") {
		i = 6;
	}
	cout << 7 - i << endl;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()

for c in ascii_lowercase:
	if c not in S:
		print(c)
		break
else:
	print("None")


Measured memory_bytes: 5464
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    int n;
    string s;
    cin >> n >> s;
    int l = 0, r = n;
    while((l + 1) < r) {
        int m = (l + r) / 2;
        bool f = [&]() {
            rep(i, n - m) {
                string ss = s.substr(i, m);
                if (s.rfind(ss) >= (i + m)) return true;
            }
            return false;
        }();
        if (f) l = m;
        else r = m;
    }
    cout << l << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <complex>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;

#ifndef typeof
#define typeof __typeof__
#endif // typeof

#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define tr(c, i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define rtr(c, i) for(typeof((c).rbegin()) i = (c).rbegin(); i != (c).rend(); i++)
#define repby(i, a, b, step) for(typeof(b) i = (a); i < (b); i += (step))
#define repab(i, a, b) repby(i, (a), (b), 1)
#define rep(i, n) repab(i, 0, (n))
#define pb push_back
#define sz(c) int((c).size())

vector<bool> prime_table;
vi nprimes;

void mkprime_table(int n) {
  prime_table = vector<bool>(n+1, true);
  nprimes = vi(n+1, 0);
  prime_table[0] = prime_table[1] = false;
  for (int i = 4; i <= n; i += 2) {
    prime_table[i] = false;
  }

  for (int i = 3; i*i <= n; i += 2) {
    if (prime_table[i]) {
      for (int j = 2; i*j <= n; j++) {
        prime_table[i*j] = false;
      }
    }
  }

  int total = 0;
  for (int i = 0; i <= n; i++) {
    if (prime_table[i]) {
      total++;
    }
    nprimes[i] = total;
  }
}

int main(int argc, char **argv)
{
  vi v;
  int n;

  while (cin >> n) {
    v.pb(n);
  }

  mkprime_table(*max_element(all(v)));

  tr(v, i) {
    cout << nprimes[*i] << endl;
  }

  return 0;
}

Measured memory_bytes: 9056
"use strict";

const input = require("fs").readFileSync("/dev/stdin", "utf8");

const inputs = input.split(" ");
const A = Number(inputs[0]);
const B = Number(inputs[1]);

const main = (A, B) => {
    let add, sub, multi = 0;
    add = A + B;
    sub = A - B;
    multi = A * B;

    return  Math.max(add, sub, multi);
};

console.log(main(A, B));

Measured memory_bytes: 7372
// import chie template :) {{{
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
    std.range, std.container, std.bigint, std.ascii, std.typecons;

// }}}
// nep.scanner {{{
class Scanner
{
    import std.stdio : File, stdin;
    import std.conv : to;
    import std.array : split;
    import std.string : chomp;

    private File file;
    private char[][] str;
    private size_t idx;

    this(File file = stdin)
    {
        this.file = file;
        this.idx = 0;
    }

    private char[] next()
    {
        if (idx < str.length)
        {
            return str[idx++];
        }

        char[] s;
        while (s.length == 0)
        {
            s = file.readln.chomp.to!(char[]);
        }

        str = s.split;
        idx = 0;

        return str[idx++];
    }

    T next(T)()
    {
        return next.to!(T);
    }

    T[] nextArray(T)(size_t len)
    {
        T[] ret = new T[len];

        foreach (ref c; ret)
        {
            c = next!(T);
        }

        return ret;
    }

    void scan()()
    {
    }

    void scan(T, S...)(ref T x, ref S args)
    {
        x = next!(T);
        scan(args);
    }
}
// }}}

void main()
{
    auto cin = new Scanner;
    int n, k;
    cin.scan(n, k);
    auto l = cin.nextArray!int(n);
    l.sort!("a > b");
    writeln(sum(l[0 .. k]));
}


Measured memory_bytes: 256
e=enumerate
n,a=open(0)
a=sorted((int(i),j)for j,i in e(('0 '+a).split()))[::-1]
c=[0]*int(n)
t=10**18
for k,(i,j)in e(a[:-1],1):
  t=min(t,j)
  c[t-1]+=(i-a[k][0])*k
print(*c)

Measured memory_bytes: 24808
a, b, c, d, e, f = (int(i) for i in input().split())

used = [[-1 for i in range(3000)] for j in range(3000)]
def dfs(w,s,wa,sa):
   
    if w+s > f or e*w/100 < s:
        w -= wa
        s -= sa
        if w==0:
            return [0,0,s]
        else:
            return [100*s/(w+s), w, s]

    if used[w][s] == 1:
        return [0,0,0]
    d1 = dfs(w+100*a,s,100*a,0)
    d2 = dfs(w+100*b,s,100*b,0)
    d3 = dfs(w,s+c,0,c)
    d4 = dfs(w,s+d,0,d)
    
    dl = [d1,d2,d3,d4]
    max_n = max([d1[0], d2[0], d3[0], d4[0]])
    for x in dl:
        if x[0] == max_n:
            used[w][s] = 1
            return x

res = dfs(0,0,0,0)

print("{} {}".format(res[1]+res[2], res[2]))

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> map(H, vector<char>(W));
  rep(i, H) {
    rep(j, W) {
      cin >> map.at(i).at(j);
    }
  }
  
  bool flag;
  rep(i, H) {
    flag = true;
    rep(j, W) {
      if (map.at(i).at(j) == '#') {
        flag = false;
        break;
      }
    }
    if (flag) {
      rep(j, W)
        map.at(i).at(j) = 'x';
    }
  }
  rep(j, W) {
    flag = true;
    rep(i, H) {
      if (map.at(i).at(j) == '#') {
        flag = false;
        break;
      }
    }
    if (flag) {
      rep(i, H)
        map.at(i).at(j) = 'x';
    }
  }
  
  rep(i, H) {
    flag = false;
    rep(j, W) {
      if (map.at(i).at(j) != 'x') {
        flag = true;
        cout << map.at(i).at(j);
      }
    }
    if (flag)
      cout << endl;
  }
}

Measured memory_bytes: 256
const config = {
    input: '/dev/stdin',
    newline: '\n'
};

const line = require('fs').readFileSync(config.input, 'utf-8').split(config.newline);

let count = 0;

const bsort = arr => {
    let flag = true;
    while (flag) {
        flag = false;
        for (let i = arr.length-1; i > 0; i--) {
            if (arr[i] < arr[i-1]) {
                const tmp = arr[i];
                arr[i] = arr[i-1];
                arr[i-1] = tmp;
                flag = true;
                count++;
            }
        }
    }

    return arr;
};

console.log(bsort(line[1].split(' ').map(x => parseInt(x))).join(' '));
console.log(count);



Measured memory_bytes: 15420
N, K = map(int, input().split())
A = list(map(int, input().split()))

ball = [0]*N
count = 0
kind = 0

for i in range(N):
    ball[A[i]-1] += 1

ball.sort(reverse=True)

for i in range(len(ball)):
    if ball[i] > 0:
        kind += 1
    if kind > K:
        count += ball[i]

print(count)


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

long long int N, C, d[3][33], D[33][33], c, i[3], a;

int main(){
    scanf("%lld%lld", &N, &C);
    for(int i = 0; i < C; ++i)
        for(int j = 0; j < C; ++j)scanf("%lld", D[i] + j);
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < N; ++j){
            scanf("%lld", &c);
            ++d[(i + j) % 3][c - 1];
        }
    }
    a = 124935826435924053;
    for(i[0] = 0; i[0] < C; ++i[0]){
        for(i[1] = 0; i[1] < C; ++i[1]){
            if(i[0] == i[1])continue;
            for(i[2] = 0; i[2] < C; ++i[2]){
                if(i[0] == i[2] || i[1] == i[2])continue;
                c = 0;
                for(int j = 0; j < 3; ++j){
                    for(int k = 0; k < C; ++k){
                        c += d[j][k] * D[k][i[j]];
                    }
                }
                a = min(a, c);
            }
        }
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 256
// Aizu 1192: Tax Rate Changed
// 2017.9.14 bal4u@uu
#include <stdio.h>

int main()
{
	int x, y, s, p1, p2, t, ans;

	while (scanf("%d%d%d", &x, &y, &s) && x) {
		for (ans = 0, p1 = 1; p1 < s; p1++) for (p2 = p1; p2 < s; p2++) {
			if ((p1*(100+x))/100 + (p2*(100+x))/100 != s) continue;
			if ((t = (p1*(100+y))/100 + (p2*(100+y))/100) > ans) ans = t;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, m, a;
  in2(n, m);
  rep2(i, 1, 105000000){
    if(m % i == 0){
      if(n * i <= m)
        a = max(a, i);
      if(n * (m / i) <= m)
        a = max(a, (m / i));
    }
  }
  out(a);
  memi;
}

Measured memory_bytes: 256
<?php
  
fscanf(STDIN,"%s",$s);
$res = array();

for($i=0;$i<strlen($s);$i++){
  for($j=$i;$j<strlen($s);$j++){
    	if($s[$j]!='A'&&$s[$j]!='G'&&
           $s[$j]!='C'&&$s[$j]!='T'){
          $res[] = ($j-$i);
          break;
        }elseif(strlen($s) == $j+1){
          $res[] = $j-$i+1;
        }
    }
}

if(count($res) == 0){
     echo (strlen($s))."\n";
}else{
  
	echo max($res)."\n";
}
    
    


Measured memory_bytes: 4604
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll n; cin >> n;
	map<string,ll> mp;
	rep(i,n){
		string s; cin >> s;
		mp[s]++;
	}
	cout << mp.size() << endl;
}

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

using namespace std;

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

  int s; 
  cin >> s;
  set<int> hash;
  int res = 1;
  while (hash.find(s) == hash.end()) {
    hash.insert(s);
    s = (s%2 == 0 ? s/2 : 3*s+1);
    ++res;
  }
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ACB130A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, a;
            var word = Console.ReadLine().Split(' ');
            x = int.Parse(word[0]);
            a = int.Parse(word[1]);
            
            if (x<a)
            {
                Console.WriteLine(0);
            }
            else if (x>=a)
            {
                Console.WriteLine(10);
            }
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

ll l[30];

void solve(){

    ll m,n;
    cin >> m >> n;
    l[0]=m;
    for(ll i=1; i<30; i++){
        l[i] = (l[i-1]*l[i-1]) % MOD;
    }

    ll tmp = n;
    ll ans = 1;
    rep(i,30){
        if(tmp%2==1){
            ans = (ans*l[i]) % MOD;
        }
        tmp /= 2;
    }

    cout << ans << endl;

}


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



Measured memory_bytes: 3232
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999

vector<vector<int>> data(10,vi(10));
ll ans=0;
int h,w,c;

void paint(int y, int x, vector<vi> &tmp,int color, int origin_color){
    tmp[y][x] = color;
    int dy[]={1,0,-1,0}, dx[]={0,1,0,-1};
    
    rep(i,4){
        int ddy = y+dy[i], ddx = x+dx[i];
        if( ddx<0 || ddy<0 || ddx>=w || ddy>=h || tmp[ddy][ddx]!=origin_color )continue;
        paint( ddy, ddx, tmp, color, origin_color );
    }
}


int count(int y,int x, vector<vi> tmp,vector<vector<bool>> &used, int color){
    used[y][x]=true;
    int c=1;
    int dy[]={1,0,-1,0}, dx[]={0,1,0,-1};
    
    rep(i,4){
        int ddy = y+dy[i], ddx = x+dx[i];
        if( ddx<0 || ddy<0 || ddx>=w || ddy>=h || used[ddy][ddx] || tmp[ddy][ddx]!=color )continue;
        c+=count( ddy, ddx, tmp, used, color);
    }
    return c;
}


void solve(vi changed){
    vector<vi> tmp = data;
    
    rep(i,changed.size()){
        if( tmp[0][0]==changed[i] )continue;
        paint(0,0,tmp,changed[i],tmp[0][0]);
    }
    

    vector<vector<bool>> used(10,vector<bool>(10,false));
    ans = max<ll>( count(0,0,tmp,used,tmp[0][0]) , ans );
}


void dfs(int f,vi changed){
    if(f>=4){
        changed.pb(c);
        solve(changed);
        return ;
    }
    rep(i,6){
        changed.pb(i);
        dfs(f+1,changed);
        changed.pop_back();
    }
}

int main(){
    while(cin>>h>>w>>c&&(h||w||c)){
        c--;
        ans=0;
        rep(i,10)rep(j,10)data[i][j]=-1;
        rep(i,h) rep(j,w){
            cin>>data[i][j];
            data[i][j]--;
        }
        
        vi changed;
        dfs(0,changed);
        
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3204
#include<iostream>
#include<cstring>
using namespace std;
char s[202];
int n;
bool flag=0;
int main(){
    cin>>s;
    n=strlen(s)-1;
    for(int i=0;i<=n;i++){
        if(s[i]=='C')flag=1;
        if(flag&&s[i]=='F'){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
//Awwawa! Dis cold yis ratten buy tEMMIE!
#include <bits/stdc++.h>
#define ll long long
#define maxn 2000005 /*rem*/
#define mod 998244353
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

using namespace std;
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
const int S = 10000005;
int nx[S][3];
int tr[S];
int rt = 1;
int idcnt = 2;
int tp[S];
void down(int k) {
	if (tp[k]) {
		swap(nx[k][1], nx[k][2]);
		for (int j = 0; j < 3; j++)
			tp[nx[k][j]] ^= 1;
		tp[k] = 0;
	}
}
void pl(int k) {
	if (tr[k] != -1) return ;
	down(k);
	int r[3] = {nx[k][0], nx[k][1], nx[k][2]};
	for (int j = 0; j < 3; j++)
		nx[k][j] = r[(j + 2) % 3];
	pl(nx[k][0]);
}
int pw[maxn];
char u[maxn];
int mr[maxn], p[maxn];
int main() {
	int n;
	cin >> n;
	pw[0] = 1;
	for (int i = 1; i <= n; i++)
		pw[i] = pw[i - 1] * 3;
	memset(tr, -1, sizeof(tr));
	for (int i = 0; i < pw[n]; i++) {
		int pl = rt, cur = i;
		for (int j = 0; j < n; j++) {
			int ne = cur % 3;
			cur /= 3;
			if (!nx[pl][ne]) nx[pl][ne] = idcnt++;
			pl = nx[pl][ne];
		}
		tr[pl] = i;
	}
//	cout << idcnt << endl;
	scanf("%s", u);
	int l = strlen(u);
	for (int j = 0; j < l; j++) {
		if (u[j] == 'S') tp[rt] ^= 1;
		else 
			pl(rt);
	}
	for (int i = 0; i < pw[n]; i++) {
		int pl = rt, cur = i;
		for (int j = 0; j < n; j++) {
			int ne = cur % 3; cur /= 3;
			down(pl);
			pl = nx[pl][ne];
		}
		mr[i] = tr[pl];
		p[mr[i]] = i;
	}
	for (int j = 0; j < pw[n]; j++)
		printf("%d ", p[j]);
	return 0;
}


Measured memory_bytes: 55792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    int ans1, ans2;
    sort(a.begin(), a.end());
    ans1 = a[n-1];
    if(ans1&1) {
        int can1 = ans1/2, can2 = ans1/2+1;
        int mi = 1e9;
        for(int i = 0; i < n-1; i++) {
            if(abs(a[i]-can1) < mi) {
                ans2 = a[i];
                mi = abs(a[i]-can1);
            }
        }
        for(int i = 0; i < n-1; i++) {
            if(abs(a[i]-can2) < mi) {
                ans2 = a[i];
                mi = abs(a[i]-can2);
            }
        }
    }else{
        int can = a[n-1]/2;
        int mi = 1e9;
        for(int i = 0; i < n-1; i++) {
            if(abs(can-a[i]) < mi){
                ans2 = a[i];
                mi = abs(a[i]-can);
            }
        }
    }
    cout << ans1 << " " << ans2 << endl;
 
}

Measured memory_bytes: 768
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
b_res=[0]*n
c_res=[0]*n
j=0
cnt=0
for i in range(n):
    res=b[i]
    cnt=bisect.bisect_left(a,res)
    b_res[i]=cnt
    res=c[i]
    cnt=bisect.bisect_left(b,res)
    c_res[i]=cnt
cntb=[0]*n
cntb[0]=b_res[0]
for i in range(1,n):
    cntb[i]=cntb[i-1]+b_res[i]
ans=0
for i in range(n):
    cnt=c_res[i]
    if cnt==0:
        continue
    else:
        ans+=cntb[cnt-1]
print(ans)

Measured memory_bytes: 106964
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
ll MOD = 1000000007;
ll INF =1<<30;
ll dp[110][100100];

int main(){
   ll a,b,c;
   cin >> a>>b>>c;
   if((c-a-b)<=0) cout << "No"<<endl;
   else if(4*a*b<(c-a-b)*(c-b-a)) cout << "Yes" <<endl;
   else cout << "No" <<endl; 
}

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

using namespace std;
const int maxn = 1e5+10;
const int inf = 0x3f3f3f3f;

int n;
int niz[maxn];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", niz+i);

    int sum = abs(niz[n]);
    for (int i = 1; i <= n; i++)
        sum += abs(niz[i - 1] - niz[i]);

    //printf("%d\n", sum);
    for (int i = 1; i <= n; i++)
        printf("%d\n", sum - abs(niz[i] - niz[i - 1]) - abs(niz[i] - niz[i + 1]) + abs(niz[i - 1] - niz[i + 1]));
    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

#include<list>

// size, push_back, pop_back, insert, erase

const int MAX_N = 3000000;
char cmd[MAX_N];
int arg[MAX_N];

int main() {

	int N;
	cin >> N;

	rep(i, N){

		// string command;
		// cin >> command;
		char command[20];
		scanf("%s", command);

		// cerr << "X";
		if (command[0] == 'i') {
			cmd[i] = 'I';
			cin >> arg[i];
		}
		else if (command[6] == 'F') {
			cmd[i] = 'F';
		}
		else if (command[6] == 'L') {
			cmd[i] = 'L';
		}
		else {
			cmd[i] = 'D';
			cin >> arg[i];
		}
	}
	
	list<int> lst;
	rep(i, N){
		if (cmd[i] == 'I'){ lst.push_front(arg[i]); }
		if (cmd[i] == 'D'){
			for (list<int>::iterator it = lst.begin(); it != lst.end(); it++){
				if (*it == arg[i])
				{
					lst.erase(it);
					break;
				}
			}
		}
		if (cmd[i] == 'F'){ lst.pop_front(); }
		if (cmd[i] == 'L'){ lst.pop_back(); }
	}

	for (list<int>::iterator it = lst.begin(); it != lst.end(); it++){
		if (it != lst.begin()) { cout << ' '; }
			cout << *it;
	}
	cout << endl;

}

Measured memory_bytes: 40616
# ruisekiwa by numpy

import numpy as np

N,K = map(int,input().split())
p = np.array(list(map(int,input().split())))

b=np.concatenate([np.array([0]),np.cumsum(p)])

K_sum = b[K:] - b[:-K]
    
print((max(K_sum)+K)/2)


Measured memory_bytes: 33700
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

using namespace std;

int main(){

    int a,b,c;
    cin >> a >> b >> c;

    if(a == b){
        cout << c << endl;
    }else{
        if(a == c){
            cout << b << endl;
        }else{
            cout << a << endl;
        }
    }
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    double R;
    cin>>R;
    cout<<setprecision(15)<<2*R*3.14159265358979323846264<<endl;
    return 0;
}


Measured memory_bytes: 3784
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;

/**
 * for (int i = 0; i < N; i++) {}
 * System.out.println();
 * HashMap<Integer, Integer> hm = new HashMap<>();
 * int[] s = new int[M];
 * ArrayDeque<Integer> deq = new ArrayDeque<>();
 *
 */
public class Main implements Runnable { //クラス名はMain1

	public static void main(String[] args) {
		Thread.setDefaultUncaughtExceptionHandler((t, e) -> System.exit(1));
		new Thread(null, new Main(), "", 1024 * 1024 * 1024).start(); //16MBスタックを確保して実行
	}

	public void run() {
		FastScannerMain1 sc = new FastScannerMain1(System.in);

		try {
			//String S = sc.nextLine().trim();
			int N = sc.nextInt();
			int M = sc.nextInt();
			Req[] r = new Req[M];
			//long l = sc.nextLong();
			//ArrayList<Integer> arr = new ArrayList<Integer>();
			for (int i = 0; i < M; i++) {
				Req req = new Req();
				req.setStart(sc.nextInt());
				req.setEnd(sc.nextInt());
				r[i] = req;
			}

			Arrays.sort(r, new Comparator<Req>() {
				public int compare(Req req1, Req req2) {
					return req1.getEnd() - req2.getEnd();
				}
			});

			int count = -1;
			int ans = 0;
			for (int i = 0; i < M; i++) {
				if (r[i].getStart() >= count) {
					count = r[i].getEnd();
					ans++;
				}
			}

			System.out.println(ans);

		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}

class Req {
	private int start;
	private int end;

	public int getStart() {
		return start;
	}

	public void setStart(int start) {
		this.start = start;
	}

	public int getEnd() {
		return end;
	}

	public void setEnd(int end) {
		this.end = end;
	}
}

//高速なScanner
class FastScannerMain1 {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScannerMain1(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}


Measured memory_bytes: 47392
// Example program
#include <iomanip>
#include <iostream>
using namespace std;

int main()
{
  double r;
  cin >> r;
  double p = 3.141592653589;
  cout << fixed << setprecision(6) << r*r*p << " " << fixed << setprecision(6) << r*2*p << endl;
  return 0;
}


Measured memory_bytes: 3236
#import<bits/stdc++.h>
#define sorted(vector) sort(vector.begin(),vector.end())
#define append(a) push_back(a)
#define int(a) stoi(a)
#define str(a) to_string(a)
using namespace std;


int a,b,c,x,g;
string s,t,r;

int main(void){
    cin>>a>>b>>c;
    if ((a+b)>=10){
        cout<<"error"<<endl;
    }else{
        cout<<a+b<<endl;
    }

}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)

const int maxn = 1 << 19;
int mx[maxn << 1], siz;

void init(int n) {
	for (siz = 1; siz < n; siz <<= 1) ;
	memset(mx, 0, sizeof(mx));
}

void upd(int i, int a, int b, int x, int v) {
	if (a + 1 == b) {mx[i] = v; return ;}
	int m = (a + b) >> 1;
	if (x < m) upd(i << 1, a, m, x, v);
	else upd(i << 1 | 1, m, b, x, v);
	mx[i] = max(mx[i << 1], mx[i << 1 | 1]);
}

int qry(int i, int a, int b, int v, vector <int> &vec) {
	if (mx[i] < v) return v;
	if (a + 1 == b) {vec.pb(a); return mx[i];}
	int m = (a + b) >> 1;
	if (v < mx[i << 1]) v = qry(i << 1, a, m, v, vec);
	if (v < mx[i << 1 | 1]) v = qry(i << 1 | 1, m, b, v, vec);
	return v;
}

struct T {
	int val, fix;
	T *ls, *rs;
	T(int v) {val = v; fix = rand(); ls = rs = NULL;}
};

void split(T *x, int v, T *&a, T *&b) {
	if (!x) {a = b = NULL; return ;}
	if (x->val <= v) a = x, split(x->rs, v, a->rs, b);
	else b = x, split(x->ls, v, a, b->ls);
}

T *merge(T *a, T *b) {
	if (!a || !b) return a ? a : b;
	if (a->fix < b->fix) {a->rs = merge(a->rs, b); return a;}
	else {b->ls = merge(a, b->ls); return b;}
}

int mxv(T *x) {return x ? max(mxv(x->rs), x->val) : 0;}
void prt(T *x) {if (x) prt(x->ls), printf("%d ", x->val), prt(x->rs);}

int n, a[maxn];
T *rt[maxn];

int main() {
//	freopen("in", "r", stdin);
	srand(200);
	scanf("%d", &n);
	for (int i = 0; i < n; ++ i) scanf("%d", &a[i]);
	int m = 0;
	for (int i = 0; i < n; ++ i) {
		if (a[i] < a[i - 1]) m ++;
		rt[m] = merge(rt[m], new T(a[i]));
	}
	int n2 = n + m; init(n2);
	for (int i = 0; i <= m; ++ i) upd(1, 0, n2, i, mxv(rt[i]));
	int nw = n;
	for (int i = 0; i <= n; ++ i) {
		vector <int> vec;
		qry(1, 0, n2, 0, vec);
		++ m;
		int v = 0;
		for (int j = 0; j < vec.size(); ++ j) {
			T *a, *b;
			split(rt[vec[j]], v, a, b);
			rt[vec[j]] = a;
			upd(1, 0, n2, vec[j], mxv(a));
			v = mxv(b);
			rt[m] = merge(rt[m], b);
		}
		while (nw && mxv(rt[m]) == nw) {
			T *d; split(rt[m], nw - 1, rt[m], d); -- nw;
		}
		if (!nw) {printf("%d\n", i); break;}
		upd(1, 0, n2, m, mxv(rt[m]));
//		for (int j = 0; j <= m; ++ j)
//			prt(rt[j]); puts("");
	}
//	printf("%.3f\n", clock() * 1.0 / CLOCKS_PER_SEC);
	return 0;
}


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

typedef long long LL;
typedef long double LD;
typedef pair < int, int > PII;
typedef pair < LL, LL > PLL;
typedef pair < LD, LD > PDD;

#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
template < typename _T > inline void _DBG(const char *s, _T x) { cerr << s << " = " << x << "\n"; }
template < typename _T, typename... args > void _DBG(const char *s, _T x, args... a) { while(*s != ',') cerr << *s++; cerr << " = " << x << ','; _DBG(s + 1, a...); }

#ifdef LOCAL
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0) cout
#endif

#define M_PI acos(-1.0)

// ********************** CODE ********************** //

template < typename TP, const TP& (*F)(const TP&, const TP&) >
struct SegmentTree {
    int MAX;
    vector < TP > tree;
    SegmentTree(int n, TP zero) { MAX = 1 << (32 - __builtin_clz(n)); tree.resize(2 * MAX + 7, zero); }
    SegmentTree(int n, vector < TP > &t)
    {
        MAX = 1 << (32 - __builtin_clz(n)); tree.resize(2 * MAX + 7, 0);
        for(int i = 0; i < sz(t); i++)
            tree[i + MAX] = t[i];
        for(int i = MAX - 1; i; i--)
            tree[i] = F(tree[2 * i], tree[2 * i + 1]);
    }
    void update(int id, TP val)
    {
        id += MAX, tree[id] = val;
        while(id > 1)
        {
            id >>= 1;
            tree[id] = F(tree[2 * id], tree[2 * id + 1]);
        }
    }
    TP query(int a, int b)
    {
        int va = a + MAX, vb = b + MAX;
        TP res = F(tree[va], tree[vb]);
        while(va / 2 != vb / 2)
        {
            if(va % 2 == 0) res = F(res, tree[va + 1]);
            if(vb % 2 == 1) res = F(res, tree[vb - 1]);
            va >>= 1, vb >>= 1;
        }
        return res;
    }
};

int n, dp[500007];
LL a, b, c, d;
map < int, int > mp;
vector < PII > v;
SegmentTree < int, max > tree(5e5, 0);

int main()
{
    _upgrade
    cin >> a >> b >> c >> d >> n;
    LD res = abs(a - c) + abs(b - d);
    res *= 100.0;
    if(a > c) swap(a, c), swap(b, d);
    bool flag = 0;
    if(b > d) flag = 1, b *= -1, d *= -1;
    for(int i = 0; i < n; i++)
    {
        int x, y; cin >> x >> y;
        if(flag) y *= -1;
        if(x < a || x > c || y < b || y > d) continue;
        v.push_back({x, y});
        mp[x] = mp[y] = 1;
    }
    int cnt = 0;
    for(auto &x: mp) x.second = ++cnt;
    n = sz(v);
    for(auto &x: v)
    {
        x.first = mp[x.first];
        x.second = mp[x.second];
    }
    sort(all(v));
    for(int i = 0; i < n; i++)
    {
        dp[i] = tree.query(0, v[i].second) + 1;
        tree.update(v[i].second, dp[i]);
    }
    int mx = tree.query(0, cnt + 1);
    DBG(mx);
    res -= (LD)mx * (20.0 - (LD)M_PI * 5.0);
    assert(a <= c && b <= d);
    if(mx - 1 == min(c - a, d - b)) res += (LD)M_PI * 5.0;
    cout << fixed << setprecision(15) << res;
    return 0;
}


Measured memory_bytes: 25456
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int main() {

	ll N,K;
	cin >> N >> K;

	if (K == 0) {
		cout << N * N << endl;
		return 0;
	}

	ll ans = 0;
	for (ll b = 2; b <= N; b++) {
		if (K > b - 1) continue;
		ll itr = N / b;
		ans += itr * (b - 1 - (K - 1));
		ll left_b = N % b;
		ans += max(0LL, left_b - (K - 1));
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;
const int INF = 1 << 25;
const LL MOD = 1000000007LL;
using namespace std;

int main() {
	string s;
	cin >> s;
	string t = "";
	string _t;
	rep(i, s.size()) {
		if (s[i] != 'x') t.push_back(s[i]);
	}
	_t = t;
	reverse(ALL(_t));

	if (t != _t) {
		cout << -1 << endl;
		return 0;
	}
	vector<int> v;
	int cnt = 0;
	rep(i, s.size()) {
		if (s[i] == 'x') cnt++;
		else v.push_back(cnt), cnt = 0;
	}
	v.push_back(cnt);
	int ans = 0;
	rep(i, v.size()) {
		if (v[i] < v[v.size() - i - 1]) ans += v[v.size() - i - 1] - v[i];
	}
	cout << ans << endl;
}

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

typedef long long ll;

#define FOR(i, l, r) for (size_t i = (l); i < (r); ++i)
#define REP(i, n) FOR(i, 0, n)

using namespace std;

int main(void)
{
    string S;
    getline(cin, S);

    string ret;
    if (equal(S.end() - 1, S.end(), "s") == true)
    {
        ret = S + "es";
    }
    else
    {
        ret = S + "s";
    }

    cout << ret << "\n";
}


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

ll a[100100];
bool done[100100],ans[100100];
vector<int> g[100100];

ll solve(int u){
	int i,v,c=0;
	ll s=0ll,m=-INFLL,t;
	done[u] = true;
	for(i=(g[u].l_ength()-1); i>=0; --i){
		v = g[u][i];
		if(done[v]){
			continue;
		}
		++c;
		t = solve(v);
		s += t;
		m = max(m,t);
		if(!ans[v]){
			ans[u] = false;
			return -INFLL;
		}
	}
	if(!c){
		ans[u] = true;
		return a[u];
	}else if(c==1){
		ans[u] = (s==a[u]);
		return a[u];
	}else if(a[u]*2<s || s<a[u] || m>a[u]){
		ans[u] = false;
		return (a[u]*2-s);
	}else{
		ans[u] = true;
		return (a[u]*2-s);
	}
}

int main(void){
	int n,u,v,i;
	ll x;
	fill(done,done+100100,false);
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a[i];
	}
	for(i=1; i<n; ++i){
		cin >> u >> v;
		--u; --v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	x = solve(0);
	if(g[0].l_ength()>1 && x){
		ans[0] = false;
	}
	cout << ((ans[0])?"YES":"NO") << endl;
	return 0;
}


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

#define int long long
#define form2(i, a, b) for (int i = (a); i < (b); ++i)
#define ford2(i, a, b) for (int i = (a-1); i >= (b); --i)
#define form(i, n) form2(i, 0, n)
#define ford(i, n) ford2(i, n, 0)

#define chmax(x, v) x = max(x, (v))
#define chmin(x, v) x = min(x, (v))
#define fi first
#define se second

const long long BIG = 1000000000000000000LL;

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

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

const int MOD = 998244353;
const int borne = 2*(int)(1e5) + 5;
int fen[borne];

int getSom(int idx)
{
	int res = 0;
	while (idx > 0) {
		res += fen[idx];
		idx -= idx & (-idx);
	}
	return res;
}

int getSom(int l, int r) { if (l > r) return 0; else return getSom(r) - getSom(l-1); }

void inc(int idx)
{
	while (idx < borne) {
		fen[idx]++;
		idx += idx & (-idx);
	}
}

map<int, int> compX, compY;
pii pts[borne];
int quad[borne][4];
int nbPoints;

void docmp(vector<int> vec, map<int, int>& cmap)
{
	sort(vec.begin(), vec.end());
	int sz = vec.size();
	form(i, sz) {
		cmap[vec[i]] = i+1;
	}
}

int pm[borne];

int cmm(int x) { x %= MOD; x += MOD; x %= MOD; return x; }
void solve()
{
	cin >> nbPoints;
	vector<int> lx, ly;
	form(i, nbPoints) {
		int x, y; cin >> x >> y;
		lx.push_back(x); ly.push_back(y);
		pts[i] = {x, y};
	}
	docmp(lx, compX); docmp(ly, compY);
	form(i, nbPoints) {
		pts[i].fi = compX[pts[i].fi];
		pts[i].se = compY[pts[i].se];
	}
	sort(pts, pts+nbPoints);
	form(i, nbPoints) {
		quad[i][0] = getSom(1, pts[i].se);
		quad[i][1] = getSom(pts[i].se, borne-1);
		inc(pts[i].se);
	}
	form(i, borne) fen[i] = 0;
	ford(i, nbPoints) {
		quad[i][3] = getSom(1, pts[i].se);
		quad[i][2] = getSom(pts[i].se, borne-1);
		inc(pts[i].se);
	}

	pm[0] = 1;
	form2(i, 1, borne) {
		pm[i] = cmm(2*pm[i-1]);
	}

	int res = 0;
	vector<int> v {0,1,2,3};
	set<vector<int>> sp;
	do {
		form(c, 4) {
			vector<int> yw;
			form(i, c+1) yw.push_back(v[i]);
			bool ok = false;
			for (int a : yw) for (int b : yw) if (a%2 == b%2 && a != b) ok = true;
			if (!ok) continue;
			sort(yw.begin(), yw.end());
			sp.insert(yw);
		}
	} while (next_permutation(v.begin(), v.end()));
	form(i, nbPoints) {
		for (auto yw : sp) {
			int subCnt = 1;
			for (int x: yw) {
				subCnt = cmm(subCnt * cmm(pm[quad[i][x]]-1));
			}
			res = cmm(res + subCnt);
		}
		res = cmm(res + pm[nbPoints-1]);
	}
	cout << res << "\n";
}


Measured memory_bytes: 43464
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
#include <cctype>
#include <cstdio>
#include <math.h>
using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
const int AMAX = 100000; 
using namespace std;
#define rep(i, n) for (i64 i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (i64 i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
#define UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define down(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
using LL = long long;
using ULL = unsigned long long;
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;
}

int main(void) {
    string a, b;
    int c;
    cin >> a >> b;
    a = a + b;
    c = atoi(a.c_str());
    for (int i = 0; i < 10000; i++)
    {
        if((i*i)==c){
            cout <<"Yes";
            return 0;
        }
    }
    cout <<"No";
    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)
using ll = long long;

int main() {
    ll n, m; cin >> n >> m;
    vector<pair<ll, ll>> a(n); REP(i, n) cin >> a[i].first >> a[i].second;
    sort(a.begin(), a.end());

    ll sum = 0; ll num = 0; ll cur = 0;
    while(num < m) {
        ll tmp = min(a[cur].second, m - num);
        sum += a[cur].first * tmp;
        num += tmp;
        ++cur;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string s;
    cin >> s;
    if(s[2]==s[3] && s[4]==s[5]) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256