akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
void f(int a[][52],int b[][52],int x,int y){
  if(a[x][y]==0&&b[x][y]==0){
    b[x][y]=1;
    f(a,b,x-1,y);
    f(a,b,x,y-1);
    f(a,b,x+1,y);
    f(a,b,x,y+1);
  }
  return;
}
int main(){
  int i,j;
  int a[52][52],b[52][52],c[52][52],p,q,w,h;
  char s;
  while(cin>>w>>h&&w+h){
    memset(a,-1,sizeof(a));
    for(i=1;i<h+1;i++){
      for(j=1;j<w+1;j++){
	cin>>s;
	if(0){
	}else if(s=='.'){
	  a[j][i]=0;
	}else if(s=='B'){
	  a[j][i]=1;
	}else if(s=='W'){
	  a[j][i]=2;
	}
      }
    }
    memset(b,0,sizeof(b));
    memset(c,0,sizeof(c));
    for(i=1;i<h+1;i++){
      for(j=1;j<w+1;j++){
	if(0){
	}else if(a[j][i]==1){
	  f(a,b,j-1,i);
	  f(a,b,j,i-1);
	  f(a,b,j+1,i);
	  f(a,b,j,i+1);
	}else if(a[j][i]==2){
	  f(a,c,j-1,i);
	  f(a,c,j,i-1);
	  f(a,c,j+1,i);
	  f(a,c,j,i+1);
	}
      }
    }
    p=q=0;
    for(i=1;i<h+1;i++){
      for(j=1;j<w+1;j++){
	if(b[j][i]&&c[j][i]==0)
	  p++;
	if(b[j][i]==0&&c[j][i])
	  q++;
      }
    }
    cout<<p<<" "<<q<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
N, T = map(int, input().split(" "))
t = list(map(int, input().split(" ")))

shower = 0

for i in range(0, N-1):
    if t[i+1]-t[i] >= T:
        shower += T
    else:
        shower += t[i+1]-t[i]

shower += T
print(shower)


Measured memory_bytes: 26832
#include<bits/stdc++.h>
using namespace std;
int main(){
  string str;
  cin>>str;
  if(str=="Sunny")
    cout<<"Cloudy\n";
  else if(str=="Cloudy")
    cout<<"Rainy\n";
 else if(str=="Rainy")
   cout<<"Sunny\n";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;

map<int, int> m;

signed main(){
    IOS;
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        m[a[i]]++;
    }
    int ans = 0;
    for (auto i : m) {
        ans += (i.se)*(i.se-1)/2;
    }
    for (int i = 0; i < n; i++) {
        if (m[a[i]] >= 2) cout << ans + (m[a[i]]-1)*(m[a[i]]-2)/2 - (m[a[i]] * (m[a[i]]-1)/2) << endl;
        else cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 11136
/*
    Problem 3
    https://atcoder.jp/contests/abc122/tasks/abc122_b
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
vector<char> atcg {'A', 'T', 'C', 'G'};
/* function */
void solve1() {
    // 尺取法による解答
    string S;
    cin >> S;
    int lenATCG = 0;
    int r = 0;
    for (int l = 0; l < S.size(); l++) {
        while (r < S.size() && count(atcg.begin(), atcg.end(), S[r]))
            r++;
        lenATCG = max(lenATCG, r - l);
        l = r;
        r++;
    }
    cout << lenATCG << '\n';
}

void solve2() {
    // 部分列の右と左端のペアを全探索する解法
    string S;
    cin >> S;
    int lenATCG = 0;
    for (int i = 0; i < S.size(); i++) {
        for (int j = i; j < S.size(); j++) {
            bool isATCG = true;
            for (int k = i; k <= j; k++)
                if (count(atcg.begin(), atcg.end(), S[k]) == 0) isATCG = false;
            if (isATCG) lenATCG = max(lenATCG, j - i + 1);
        }
    }
    cout << lenATCG << '\n';
}
/* main */
int main(){
    solve1();
    // solve2();
}

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

#define ll long long
#define ull unsigned long long
#define f first
#define s second
typedef pair<int , int > pii;
typedef pair<ll,ll> pll;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set

const ll MOD = 1e9+7;

void min_self(ll &a , ll b){a=min(a,b);}
void max_self(ll &a, ll b){a=max(a,b);}
ll add(ll x, ll y){return (x + y) % MOD;}
ll sub(ll x, ll y){return add(x, MOD - y);}
ll mul(ll x, ll y){return (x * 1ll * y) % MOD;}
ll binpow(ll x, ll y)
{   ll z = 1;
    while(y > 0)
    {if(y % 2 == 1) z = mul(z, x);
        x = mul(x, x);
        y /= 2;
    }
    return z;
}
ll inv(ll x){return binpow(x, MOD - 2);}
const int MXN = 1e6+10;
ll fact[MXN];
void fac_pre()
{
    fact[0]=1;
    for(ll i=1; i<MXN; i++){
        fact[i]=mul(fact[i-1],i);
    }
}
ll C(ll n, ll k)
{
    return mul(fact[n], inv(mul(fact[k], fact[n - k])));
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}
///--//

int  main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen ("output.txt","w",stdout);
    /* KEEP IN MIND
     * take care when sorting a 1 based indexed vector
     * use greater<ll> for ll's
    */
    string s; cin>>s;
    ll sum=0;
    for(int i=0; i<s.length(); i++){
        sum+=s[i]-'0';
    }
    if(sum % 9 ==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

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

int main() {
  
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  
  int m = 0;
  m = max(a, b);
  m = max(m, c);
  int sum = 0;
  sum = a+b+c - m;
  for(int i = 0; i < k; i++) {
    m *= 2;
  }
  
  cout << sum + m << endl;
  
}

Measured memory_bytes: 256
"""
まあまずは愚直にOrder（N*N）でやろう
これナイーブ計算というらしい
→無理でした。

前処理でWの累積和を計算する
そのあとにインデックス回して最小値を計算する
確かに前処理がO(N)でできるなら、
O(N)　＋　O（N）で計算可能になる！！
"""

INF = 1000000
N = int(input())
S = input()
ans = INF

sum_n = [0]
add_n = 0
# 前処理
# Westを向いている人の数を数える
for s in S:
  if s == "W":
    add_n += 1
  sum_n.append(add_n)

# リーダーの添字 = i
for i in range(N):
  # i番目より西にいる人のWを向いている人の数
  if i > 0:
    b_i = sum_n[i] - sum_n[0]
  else:
    b_i = 0

  # i番目より東にいる人のWを向いている人の数
  if i < N:
    f_i = (N - (i + 1)) - (sum_n[N] - sum_n[i+1])
  else:
    f_i = 0
  
  tmp = b_i + f_i
  ans = min(ans, tmp)

print(ans)


Measured memory_bytes: 15516
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.BufferedInputStream;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author MaxHeap
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABlackjack solver = new ABlackjack();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABlackjack {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int[] ints = in.nextIntArray(3);
            int sum = 0;
            for (int anInt : ints) {
                sum += anInt;
            }
            if (sum >= 22) {
                out.println("bust");
            } else {
                out.println("win");
            }
        }

    }

    static class InputReader {
        private StringTokenizer st;
        private BufferedReader reader;

        public InputReader(InputStream is) {
            st = null;
            reader = new BufferedReader(new InputStreamReader(new BufferedInputStream(is, 1 << 18)));
        }

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

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

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

    }
}



Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  vector<vector<ll>> dp(n+1, vector<ll>(n+1, LINF));
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= i; j++) {
      rep(l, i) {
        if (l)
          chmin(dp[i][j], dp[l][j-1]+max(h[i-1]-h[l-1], 0));
        else
          chmin(dp[i][j], dp[l][j-1]+h[i-1]);
      }
    }
  }
  ll ans = LINF;
  rep(i, n+1)
    chmin(ans, dp[i][n-k]);
  cout << ans << endl;
  return 0;
}

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

int main(){
    ll h,w;
    ll ans;
    cin>>h>>w;
    if(h==1 || w==1){
        ans = 1;
    }else if(h%2==1 && w%2==1){
       ans = (h*w) / 2 + 1;
    }else{
       ans = (h*w) / 2;
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef complex<double> pnt;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, pii> pp;
typedef double ld;
typedef long double lld;
#define INF 0x3f3f3f3f // for int
#define LL_INF 0x3f3f3f3f3f3f3f3f // for ll
#define ms(x, y) memset(x, y, sizeof(x))
//coordinate compression:sort(val.begin(), val.end());
//		val.resize(unique(val.begin(), val.end()) - val.begin());
#define nl '\n'
typedef unsigned long long ull;
const lld pi = 3.14159265358979323846;
const int MOD = 1e9 + 7;

//remember to remove ios stuff if i use scanf

//printf("%05lld\n", x); --> print last 5 digits including 0's
//printf("%02d:%02d", h, m); --> time
ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll pwmd(ll b, ll exp) {
    ll ret = 1;
    while (exp > 0) {
        if (exp % 2 == 1) ret = (ret * b) % MOD;
        exp /= 2;
        b = (b * b) % MOD;
    }
    return ret;
}
//void RotateArr(int X) {
//    for (int n=0; n<X; n++) {
//        for (int i=0; i<N/2; i++) {
//            for (int j=0; j<N; j++) {
//                swap(a[i][j], a[N-i-1][j]);
//            }
//        }
//        for (int i=0; i<N; i++) {
//            for (int j=i+1; j<N; j++) {
//                swap(a[i][j], a[j][i]);
//            }
//        }
//    }
//}

/*
 * string input;
 *
 * stringstream ss(input);
 *- if the input contains '\n', separate lines with: string line; while (getline(ss, line))
 * - clear() to clear the stream
 * - >> : read smth from stringstream object ie. while (s >> word)
 */

struct pair_hash { //--> for unordered_set<pair<ll, ll>>
    //initialize the set with unordered_set<pair<ll, ll>, pair_hash>st
    inline std::size_t operator()(const std::pair<ll,ll> & v) const {
        return v.first*31+v.second;
    }
};
/* for dijkstra:
 * bool operator < (const E &other) const {
        return this->w > other.w;
    }
 */

int x;

void solve(int tc) {
    
    cin >> x;
    if (x == 0) cout << 1 << nl;
    else cout << 0 << nl;

}

//you should really read the stuff at the bottom

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

    int tc = 1; //cin >> tc;
    for (int t = 1; t <= tc; t++) solve(t);

    return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
	* DON'T GET STUCK ON ONE APPROACH
// Did you read the bounds?
// Did you make typos?
// Are there edge cases (N=1?)
// Are array sizes proper (scaled by proper constant, for example 2* for koosaga tree)
// Integer overflow?
// DS reset properly between test cases?
// Is using long longs causing TLE?
// Are you using floating points?
*/

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

using namespace std;

int n;
vector<int> na,cnt;

int solve() {
  int res=n;
  queue<int> q;
  for(int i=0;i<n;++i)
    if(cnt[i]==0) q.push(i);
  while(!q.empty()) {
    int e=q.front(); q.pop();
    cnt[na[e]]--; res--;
    if(cnt[na[e]]==0) q.push(na[e]);
  }
  return res;
}

int main(){
  cin >> n;
  na.resize(n);
  cnt.assign(n,0);
  for(int i=0;i<n;++i) {
    int a; cin >> a;
    na[i]=(i+a)%n;
    cnt[na[i]]++;
  }
  cout << solve() << endl;
  
  return 0;
}



Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int H, W;
int N;
int a[10010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> H >> W >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  int y = 0, x = 0, d = 1;
  int c[110][110];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < a[i]; j++) {
      c[y][x] = i + 1;
      if (d > 0 && x == W - 1) y++, d = -1;
      else if (d < 0 && x == 0) y++, d = 1;
      else x += d;
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << c[i][j] << " \n"[j + 1 == W];
    }
  }

  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cassert>
#include <algorithm>

int main(int argc, char **argv)
{
    int A, B, C, X, Y;
    std::cin >> A >> B >> C >> X >> Y;
    assert(1 <= A && A <= 5000);
    assert(1 <= B && B <= 5000);
    assert(1 <= C && C <= 5000);
    assert(1 <= X && X <= 100000);
    assert(1 <= Y && Y <= 100000);

    long price = 0;
    int x = X;
    int y = Y;
    
    if(2 * C <= A){
        int n = x;
        price += 2 * n * C;
        x -= n;
        y -= n;
    }
    if(x <= 0 && y <= 0){
        std::cout << price << std::endl;
        return 0;
    }
    
    if(2 * C <= B){
        int n = y;
        price += 2 * n * C;
        x -= n;
        y -= n;
    }
    if(x <= 0 && y <= 0){
        std::cout << price << std::endl;
        return 0;
    }

    int price_a = price;
    int price_b = price;
    
    { // pattern A
        int n = std::min(x, y);
        price_a += 2 * n * C;
        if(x-n > 0) price_a += (x-n) * A;
        if(y-n > 0) price_a += (y-n) * B;
    }
        
    { // pattern B
        price_b += x * A + y * B;
    }

    //std::cout << "price_a:" << price_a << std::endl;
    //std::cout << "price_b:" << price_b << std::endl;
    
    std::cout << std::min(price_a, price_b) << std::endl;
        
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int fa[1010],num[1010];
bool go[1010],bo[1010];
int getf(int s){if (fa[s]==s) return s;return fa[s]=getf(fa[s]);}
int main()
{
	int n;scanf("%d%*d",&n);
	for (int i=1;i<=1000;i++) fa[i]=i;
	for (int i=1;i<=n;i++)
	{
		int a,b,c,d;scanf("%d%d%d%d",&a,&b,&c,&d);
		if (c==0) c=a+500;else c=c+1;
		if (d==0) d=b+1;else d=d+500;
		fa[getf(c)]=getf(d);
		num[c]++;num[d]--;bo[c]=true;
	}
	for (int i=1;i<500;i++) if (num[i]>0) {puts("NO");return 0;}
	for (int i=500;i<1000;i++) if (num[i]<0) {puts("NO");return 0;}
	for (int i=1;i<1000;i++)
	{
		bo[getf(i)]|=bo[i];
		go[getf(i)]|=(num[i]!=0);
	}
	for (int i=1;i<1000;i++) if ((fa[i]==i)&&(bo[i])&&(!go[i])) {puts("NO");return 0;}
	puts("YES");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define maxn 100010
#define mod 1000000007
ll tr[maxn*8],p[maxn*8];
void bu(int x,int l,int r){
    tr[x]=1e16;
    if(l==r) return ;
    bu(x*2,l,(l+r)/2);
    bu(x*2+1,(l+r)/2+1,r);
}
void up(int x){
    if(p[x]){
        if(p[x*2]==0) p[x*2]=p[x];
        else p[x*2]=min(p[x*2],p[x]);
        if(p[x*2+1]==0) p[x*2+1]=p[x];
        else p[x*2+1]=min(p[x*2+1],p[x]);
        tr[x*2]=min(tr[x*2],p[x]);
        tr[x*2+1]=min(tr[x*2+1],p[x]);
        p[x]=0;
    }
}
ll fi(int x,int l,int r,int y){
    if(y==1) return 0;
    if(l==r) return tr[x];
    up(x);
    if((l+r)/2>=y) return fi(x*2,l,(l+r)/2,y);
    return fi(x*2+1,(l+r)/2+1,r,y);
}
void cg(int x,int l,int r,int s,int e,ll y){
    if(l>=s&&r<=e){
        if(p[x]==0) p[x]=y;
        else p[x]=min(p[x],y);
        tr[x]=min(tr[x],y);
        return ;
    }
    up(x);
    int mid=(l+r)/2;
    if(mid>=e) cg(x*2,l,mid,s,e,y);
    else if(mid<s) cg(x*2+1,mid+1,r,s,e,y);
    else{
        cg(x*2,l,mid,s,e,y);
        cg(x*2+1,mid+1,r,s,e,y);
    }
}
struct cv{
    int l,r;
    ll c;
}a[maxn];
bool cmp(cv p,cv q){
    if(p.l!=q.l) return p.l<q.l;
    if(p.r!=q.r) return p.r<q.r;
    return p.c<q.c;
}
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++){
        scanf("%d%d%lld",&a[i].l,&a[i].r,&a[i].c);
    }
    sort(a,a+m,cmp);
    int li=1;
    for(int i=0;i<m;i++){
        if(a[i].l>li){
            printf("-1\n");
            return 0;
        }
        li=max(li,a[i].r);
    }
    if(li!=n){
        printf("-1\n");
        return 0;
    }
    bu(1,1,n);
    for(int i=0;i<m;i++) cg(1,1,n,a[i].l+1,a[i].r,fi(1,1,n,a[i].l)+a[i].c);
    printf("%lld\n",fi(1,1,n,n));
    return 0;
}

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

int main() {
  
  string a, b; cin >> a >> b;
  
  int x = stoi(a + b);
  
  for (int i = 0; i * i <= x; i++) {
    if (pow(i, 2) == x) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  cout << "No" << endl;
  
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
    char s[200005];
    scanf("%s",s);
    int n = strlen(s);
    if(s[n - 1] == '?')
        s[n - 1] = 'D';
    for(int i = n - 1; i > 0; i--){
        if(s[i] == 'P' || s[i] == 'D')
            continue;
        if(s[i - 1] == 'P')
            s[i] = 'D';
        else if(i != n - 1 && s[i + 1] == 'D')
            s[i] = 'P';
        else 
            s[i] = 'D';
    }
    if(s[0] == '?'){
        if(s[1] == 'D')
            s[0] = 'P';
        else 
            s[0] = 'D';
    }
    printf("%s",s);
    return 0;
}

Measured memory_bytes: 1900
#include <stdio.h>
#include <math.h>

int nums1[105];
int nums2[105];

int main() {
#ifdef TEST
    freopen("input", "r", stdin);
#endif
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &nums1[i]);
    }

    double maxn = 0;
    double ans1 = 0;
    double ans2 = 0;
    double ans3 = 0;
    for (int i = 0; i < n; ++i) {
        scanf("%d", &nums2[i]);
        nums1[i] = nums1[i] > nums2[i] ?
                nums1[i] - nums2[i] :
                nums2[i] - nums1[i];
        maxn = nums1[i] > maxn ? nums1[i] : maxn;
        ans1 += nums1[i];
        ans2 += pow(nums1[i], 2);
        ans3 += pow(nums1[i], 3);
    }

    printf("%f\n%f\n%f\n%f\n", ans1, pow(ans2, 1.0 / 2), pow(ans3, 1.0 / 3), maxn);
    return 0;
}



Measured memory_bytes: 2120
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  input! {
    n: usize,
    k: usize,
    points: [(i64, i64); n],
  }
  let mut points = points;
  points.sort();
  let mut ans = 1i64 << 62;
  for left in 0 .. n {
    let minx = points[left].0;
    for top in 0 .. n {
      for bottom in 0 .. n {
        let miny = points[bottom].1;
        let maxy = points[top].1;
        if miny > maxy {
          continue;
        }
        let mut count = 0;
        for p in left .. n {
          let p = points[p];
          if miny <= p.1 && p.1 <= maxy {
            count += 1;
            if count >= k {
              let maxx = p.0;
              ans = cmp::min(ans, (maxx - minx) * (maxy - miny));
            }
          }
        }
      }
    }
  }

  println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
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 pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int 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 = 1020000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,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 T> inline void print(T &a){
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << "debug: " << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << "debug: " << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

template<typename T> struct BIT{
	vector<T> dat;
	ll sz;
	//all 1-indexed
	BIT(ll sz) : sz(sz){
		dat.assign(++sz, 0);
	}

	T sum(ll k){
		T ret = 0;
		for(++k; k > 0; k -= k & -k) ret += dat[k];
		return (ret);
	}

	void add(ll k, T x){
		for(++k; k < dat.size(); k += k & -k) dat[k] += x;
	}
	
	ll get(T k){
		if(k <= 0) return 0; 
		ll ret = 0;
		int n = 1; while(n < sz) n *= 2;
		for(int i=n/2; i>0; i/=2){
			if(ret+i < sz && dat[ret+i] < k){
				k -= dat[ret+i];
				ret += i;
			}
		}
		return ret;
	}
};

int main(){
	ll n; cin >> n;
	vl a(n); rep(i,n) cin >> a[i];
	ll M = n * (n+1) / 2 / 2 + 1;
	ll L = 0, R = 1e9;
	BIT<ll> bit(202020);
	int p = 100000;
	while(R - L > 1){
		int m = (L + R) / 2;
		int now = 0;
		bit.add(p,1);
		ll cnt = 0;
		rep(i,n){
			int b = a[i] <= m ? 1 : -1;
			now += b;
			cnt += bit.sum(p+now-1);
			bit.add(p+now,1);
		}
		bit.add(p,-1);
		now = 0;
		rep(i,n){
			int b = a[i] <= m ? 1 : -1;
			now += b;
			bit.add(p+now,-1);
		}
		if(cnt < M) L = m;
		else R = m;
	}
	cout << R << "\n";
}

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

int main() {
  int N,M;
  int S=0;
  cin >> N >> M;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A.at(i);
    S+=A.at(i);
  }

  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  if(S%(4*M)==0){
  if(A.at(M-1)>=S/(4*M))
    cout << "Yes";

  else
    cout << "No";
  }
  else{
  if(A.at(M-1)>S/(4*M))
    cout << "Yes";

  else
    cout << "No";
  }
}


Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String []args){
    	Scanner sc = new Scanner(System.in);
    	String s = sc.next();
      
      s = s.replaceAll("eraser","@");
      s = s.replaceAll("erase","@");	
      s = s.replaceAll("dreamer","@");
      s = s.replaceAll("dream","@");

      s = s.replaceAll("@","");
      
      if(s.length() == 0)
      	System.out.println("YES");
      else
        System.out.println("NO");
    }
}

Measured memory_bytes: 28836
/*
return max(a +max(b,c),b+max(c,a),c+max(a,b));

10 40 70
90 120 120
150 180 210
*/
#include <bits/stdc++.h>
#include<stack>
using namespace std;
typedef long long ll;
typedef long double lxd;
#define INF 1000000007
#define mem(dp,a) memset(dp,a,sizeof dp)
#define flash ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define f(i,n) for (ll i=0;i<n;i++)
#define fo(i,x,n) for (ll i=x;i<=n;i++)
#define pb(x) push_back(x)
#define tr(c,it) for(((c).begin())it=(c).begin();it!=(c).end();it++)
#define test ll t; cin>>t;
#define fls fflush(stdout) ;
int main()
{
  ll n;cin>>n;
  ll a[n][3],dp[n][3];
  for(ll i=0;i<n;i++)
  {
      cin>>a[i][0]>>a[i][1]>>a[i][2];
  }
  dp[0][0]=a[0][0];dp[0][1]=a[0][1];dp[0][2]=a[0][2];
  for(ll i=1;i<n;i++)
  {
      dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
      dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
      dp[i][2]=a[i][2]+max(dp[i-1][1],dp[i-1][0]);
  }
  ll ans=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
  cout<<ans<<endl;
   return 0; 
}



Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

vector<vector<int>> g(200005);
vector<int> dp(200005);
vector<bool> visited(200005);

void bfs(int s) {
	queue<int> Q;
	Q.push(s);
	while (!Q.empty()) {
		int v = Q.front(); Q.pop();
		visited[v] = true;
		for (int to: g[v]) {
			if (visited[to]) continue;
			dp[to] += dp[v];
			Q.push(to);
		}
	}
}

int main() {
	int n, q;
	cin >> n >> q;
	rep (i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].pb(b);
		g[b].pb(a);
	}
	rep (i, q) {
		int p, x;
		cin >> p >> x;
		p--;
		dp[p] += x;
	}

	bfs(0);

	rep (i, n) cout << dp[i] << endl;
	return 0;
}

Measured memory_bytes: 15604
#include<bits/stdc++.h>
using namespace std;
int s=0;
string a;
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","r",stdout);
	cin>>a;
	for(int i=0;i<a.size();i++)
	{
		if(a[i]=='C' && s==0) s++; 
		if(a[i]=='F' && s==1) s++;
	}
	if(s==2) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

int main() {
  int N,D;
  cin >> N >> D;
  vector<vector<int>> V(N,vector<int>(D));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++)
      cin >> V.at(i).at(j);
  }
  int count = 0;
  
  for (int k = 0; k < N - 1; k++) {
    for (int l = k + 1; l < N; l++) {
      int a = 0;
      for (int m = 0; m < D; m++)
        a += (V.at(k).at(m) - V.at(l).at(m))*(V.at(k).at(m) - V.at(l).at(m));
      for (int n = 1; n < sqrt(a) + 1; n++) {
        if (n*n == a)
          count++;
      }
    }
  }
  
  cout << count << endl;
      
}

Measured memory_bytes: 3684
#include <stdio.h>

int main(void) {
	
	int N,M,i,change;
	scanf("%d",&N);
	int T[N];
	int sum=0;
	for(i=0;i<N;i++){
		scanf("%d",&T[i]);
		sum += T[i]; 
	}
	scanf("%d",&M);
	int P,X;
	for(i=0;i<M;i++){
		scanf("%d %d",&P,&X);
		change=T[P-1]-X;
		printf("%d\n",sum-change);
	}
	
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void){
	int N, K, X, Y;

	scanf("%d%d%d%d", &N, &K, &X, &Y);

	if (N <= K)printf("%d\n", N*X);

	else printf("%d\n", K*X + (N - K)*Y);

	return 0;

}




Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main
{

  public static void main
  (
    String[] args
  )
  {
    BufferedReader in_stream;
    String         in_str;
    String[]       in_str_split;

    int      in_N;
    String[] in_S;

    int     cnt;
    boolean is_four;

    try
    {
      in_stream = new BufferedReader(new InputStreamReader(System.in));

      /*----------------
       * 引数
       *----------------*/
      in_str = new String(in_stream.readLine());
      in_N   = Integer.parseInt(in_str);

      in_str = new String(in_stream.readLine());
      in_S   = in_str.split(" ");

      is_four = false;
      for(cnt=0; cnt<in_N; cnt++)
      {
        if(in_S[cnt].equals("Y"))
        {
          is_four = true;
          break;
        }
      }

      if(is_four)
      {
        System.out.println("Four");
      }
      else
      {
        System.out.println("Three");
      }
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }
}


Measured memory_bytes: 21332
a, b, c, d, e, f = list(map(int, input().split()))

ma = 0
for aa in range(0, f+1, a * 100):
    for bb in range(0, f - aa + 1, b * 100):
        water = aa + bb
        if water == 0:
            continue
        smax = min(water // 100 * e, f - water)
        for cc in range(0, smax + 1, c):
            dd = (smax - cc) // d * d
            sugar = cc + dd
            ratio = 100 * sugar / float(water + sugar)
            if ratio >= ma:
                ma = ratio
                ans = [water + sugar, sugar]

print(*ans)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

signed main() {
  int N, M; cin >> N >> M;

  priority_queue<int> PQ;
  for (int i = 0; i < N; i++) {
    int a; cin >> a;
    PQ.push(a);
  }
  for (int i = 0; i < M; i++) {
    long double x = PQ.top(); PQ.pop();
    x = floor(x/2);
    PQ.push(x);
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    int y = PQ.top(); PQ.pop();
    ans += y;
  }

  cout << ans << endl;
}


Measured memory_bytes: 1400
from collections import defaultdict
from math import gcd

N = int(input())
X = [list(map(int, input().split())) for _ in range(N)]

d = {}
for a, b in X:
    if a == b == 0:
        pass
    elif a == 0:
        if b > 0:
            b = 1
        else:
            b = -1
    elif b == 0:
        if a > 0:
            a = 1
        else:
            a = -1
    else:
        v = gcd(a, b)
        a //= v
        b //= v

    if a != 0 and a * b >= 0:
        pair = (abs(a), abs(b))
        if pair not in d:
            d[pair] = [0, 0]
        d[pair][0] += 1
    else:
        pair = (abs(b), abs(a))
        if pair not in d:
            d[pair] = [0, 0]
        d[pair][1] += 1

mod = 10 ** 9 + 7
zero = 0
ans = 1
for p in d:
    if p == (0, 0):
        zero = d[p][1]
    else:
        a, b = d[p]
        ans *= pow(2, a, mod) + pow(2, b, mod) - 1
        ans %= mod
        
print((ans + zero - 1) % mod)


Measured memory_bytes: 145472
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int k , n;
  cin >> k >> n ;
  int a[n] ;
  for ( int i=0 ; i< n ; i++){
    cin >> a[i] ;
  }
  vector<int> dis(n) ;
  for ( int i=0 ; i<n-1 ; i++){
    dis.at(i)=a[i+1]-a[i] ;
  }
  dis.at(n-1)=k-a[n-1]+a[0];
  sort(dis.begin() , dis.end() ) ;
  cout << k-dis.at(n-1) << endl ;
}

Measured memory_bytes: 4840
#include<iostream>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;

int main(){
    int n, k;
    cin >> n >> k;
    vector<ll> v(n+1, 0);
    for(int i = 1; i <= n; i++)  cin >> v[i], v[i] += v[i-1];
    map<ll,int> m;
    ll ret = 0;
    for(int i = 0; i <= n; i++){
        if(i >= k)   m[(v[i-k]-(i-k))%k]--;
        ret += m[(v[i]-i)%k];  
        m[(v[i]-i)%k]++;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 14336
#include <iostream>

using namespace std;

int main(){
  int b,r,g,c,s,t;
  while(cin >> b >> r >> g >> c >> s >> t){
    if(b == 0 && r == 0 && g == 0 && c == 0 && s == 0 && t ==0) break;
    int money =100;
    money += 77 * b;
    t -= 6 * b;
    money += 51 * r;
    t -= 4 * r;
    money += 4 * g;
    t -= g;
    money -= c;
    t -= c;
    t -= s;
    money -= 3* t;

    cout << money << endl;
  }
  
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
    int N, M;
    int L_temp, R_temp;
    vector<int> L, R;
    cin >> N >> M;
    for(int j = 0; j < M; j++){
        cin >> L_temp >> R_temp;
        L.push_back(L_temp);
        R.push_back(R_temp);
    }

    int max_L = *std::max_element(L.begin(), L.end());
    int min_R = *std::min_element(R.begin(), R.end());

    int ans;
    ans = std::max(min_R - max_L + 1,0);

    cout << ans << endl;

}



Measured memory_bytes: 1276
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		String S = next();
		long K = nextLong();
		int N = S.length();
		char[] C = S.toCharArray();

		if(N == 1) {
			out.println(K/2);
			return;
		}

		List<Integer> cntList = new ArrayList<Integer>();
		long sum = 0;
		int cnt = 1;
		for(int i=1;i<N;i++) {
			if(C[i-1] == C[i]){
				cnt++;
				if(cnt % 2 == 0) {
					sum++;
				}
				if(i == N-1)cntList.add(cnt);
			}else if(C[i-1] != C[i]) {
				cntList.add(cnt);
				cnt = 1;
			}
		}

		if(K == 1) {
			out.println(sum);
			return;
		}
		boolean f = false;
		if(K >= 2) {
			if(C[0]==C[N-1]) {
				int a = cntList.get(0);
				int b = cntList.get(cntList.size()-1);
				if(a % 2 == 1 && b % 2 == 1) {
					f = true;
				}
			}
		}

		if(f) sum=(sum+1)*(K-1)+sum;
		else sum = sum*(K-1)+sum;
		if(cntList.size()==1)sum = N*K/2;
		out.println(sum);
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

}

Measured memory_bytes: 21716
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <vector>
using namespace std;
const int MAXN = 100000;

int n, m;
int fa[MAXN+5];
int val[MAXN+5];
vector <int> blk[MAXN+5];
vector <int> ansEdge;
long long int ans;

int SetFind(int x)
{
    if(fa[x] != x)
        return fa[x] = SetFind(fa[x]);
    return fa[x];
}

void SetInit(int n)
{
    for(int i = 1; i <= n; i++)
        fa[i] = i;
}

int main()
{
    int blkcnt;

    cin >> n >> m ;
    SetInit(n);
    blkcnt = n;

    for(int i = 1; i <= n; i++)
    {
        cin >> val[i] ;
        //blk[i].push_back(val[i]);
    }


    for(int i = 1; i <= m; i++)
    {
        int u, v;
        cin >> u >> v;
        u++, v++;
        if(SetFind(u) != SetFind(v))
            fa[SetFind(u)] = SetFind(v), blkcnt--;
    }

    for(int i = 1; i <= n; i++)
        blk[SetFind(i)].push_back(val[i]);
/*
    for(int i = 1; i <= n; i++)
    {
        if(!blk[i].empty())
            cout << blk[i].size() << endl ;
    }
*/
    if(blkcnt <= 1)
    {
        cout << 0 << endl ;
        return 0;
    }

    blkcnt -= 2;

    for(int i = 1; i <= n; i++)
        if(!blk[i].empty())
        {
            sort(blk[i].begin(), blk[i].end());
            ans += blk[i][0];
            for(int k = 1; k < blk[i].size(); k++)
                ansEdge.push_back(blk[i][k]);
        }

    if(ansEdge.size() < blkcnt)
    {
        cout << "Impossible" << endl;
        return 0;
    }

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

    for(int i = 0; i < blkcnt; i++)
        ans += ansEdge[i] ;

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


Measured memory_bytes: 6528
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        int n = in.nextInt();
        int[] a = in.nextIntArray(n);
        boolean f = true;
        for (int i = 0; i < n; i++) {
            if (a[i] % 2 == 0) {
                f &= a[i] % 3 == 0 || a[i] % 5 == 0;
            }
        }
        System.out.println(f ? "APPROVED" : "DENIED");
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

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

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

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

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

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

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

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

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private static PrintWriter out = new PrintWriter(System.out);

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
    }

    void flush() {
        out.flush();
    }
}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}


ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

ll n;
vl a(0),b(0),c(0);
bool isOKc(ll index, ll key) {
    if ( c[index]>key) return true;
    else return false;
}
bool isOKa(ll index, ll key) {
    if ( a[index]>=key) return true;
    else return false;
}

// 汎用的な二分探索のテンプレ
ll binary_searchc(ll key) {
    ll ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    ll ok = (ll)n; // 「index = ha.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;

        if (isOKc(mid, key)) ok = mid;
        else ng = mid;
    }
    return ok ;
}
ll binary_searcha(ll key) {
    ll ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    ll ok = (ll)n; // 「index = ha.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;

        if (isOKa(mid, key)) ok = mid;
        else ng = mid;
    }
    return ok ;
}

int main(){
  cin>>n;
  rep(i,n){ ll aa;cin>>aa;a.push_back(aa);}
  rep(i,n){ ll bb;cin>>bb;b.push_back(bb);}
  rep(i,n){ ll cc;cin>>cc;c.push_back(cc);}
  sort(all(a));
  sort(all(b));
  sort(all(c));
  
  ll ans =0;
  rep(i,n){
    ans += (n-binary_searchc(b[i]))*binary_searcha(b[i]);
   
  }
  cout<<ans<<endl;
}
  


Measured memory_bytes: 3316
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
typedef long long ll;
using namespace std;

int main(){
    double a,b,c,d;cin>>a>>b>>c>>d;
    cout<<fixed<<setprecision(12)<<a*b/2<<' ';
    cout<<(c*2==a&&d*2==b?1:0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
char str[1005];
int main() {
	scanf("%s", str);
	int n = strlen(str);
	int up = 0, down = 0, left = 0, right = 0;
	for (int i = 0; i < n; ++i) {
		up |= str[i] == 'N';
		down |= str[i] == 'S';
		left |= str[i] == 'W';
		right |= str[i] == 'E';
	}
	if (up != down || left != right) printf("No\n");
	else printf("Yes\n");
}


Measured memory_bytes: 256
a,b,c=map(int,input().split())
d,e,f=map(int,input().split())
g,h,i=map(int,input().split())
if a+e==b+d:
    if b+f==c+e:
        if d+h==e+g:
            if e+i==f+h:
                print('Yes')
                exit()
print('No')

Measured memory_bytes: 9132
#include "bits/stdc++.h"
 
#define X first
#define Y second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define rep(i, a, b) for (long i = (a); i <= (b); ++i)
#define per(i, a, b) for (long i = (a); i >= (b); --i)
 
using namespace std;
 
using I = int;
using L = long;
using F = float;
using S = string;
using SS = stringstream;
using C = char;
using LL = long long;
using VI = vector<int>;
using VL = vector<long>;
using VF = vector<float>;
using VS = vector<string>;
using VVI = vector<vector<int>>;
using VVL = vector<vector<long>>;
using PLL = pair<long, long>;
using PLF = pair<long, float>;
using PLS = pair<long, string>;
using PSL = pair<string, long>;
using PSF = pair<string, float>;
using PSS = pair<string, string>;
using MLL = map<long, long>;
using MLF = map<long, float>;
using MLS = map<long, string>;
using MSL = map<string, long>;
using MSF = map<string, float>;
using MSS = map<string, string>;
 
const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;
 
template <class T>
void PrintVector(const vector<T> & v) {
  for (const auto & e: v) {
    cout << e << endl;
  }
}
 
template <class T>
void PrintVector(const vector<T> & v, I n) {
  rep(i, 0, n - 1) {
    cout << v[i] << endl;
  }
}
 
int main(int argc, char const *argv[]) {
  long n;
  vector<long> a;
  cin >> n;
  rep(i, 1, n) {
    long a0;
    cin >> a0;
    a.pb(a0 * 2);
  }
  long j = 0;
  long x1 = 0;
  rep(i, 0, n / 2 - 1) {
    x1 += a[i * 2] - a[i * 2 + 1];
  }
  x1 = (x1 + a[n - 1]) / 2;
  cout << x1;
  rep(i, 1, n - 1) {
    cout << " " << a[i - 1] - x1;
    x1 = a[i - 1] - x1;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 2292
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vs = vector<string>;
template <typename T>
using ost = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
#define forn(i,n) for(int i=0; i<int(n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define ff first
#define ss second

int main() {
    ios::sync_with_stdio(false);
    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    n--;
    ll lo=a, hi=a;
    forn(i, n) {
        if (lo+c+1 <= hi-c) {
            lo-=d, hi+=d;
            if (lo<=b && hi>=b) return cout<<"YES\n", 0;
        }
        else if (llabs(b-lo) < llabs(b-hi))
            tie(lo, hi) = pii(lo-d, hi-c);
        else
            tie(lo, hi) = pii(lo+c, hi+d);
    }
    if (lo<=b && hi>=b) cout << "YES\n";
    else cout << "NO\n";
}


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

def selectionSort(A, N):
    counter = 0
    for i in range(N):
        minj = i
        for j in range(i, N):
            if A[j] < A[minj]:
                minj = j
        if i != minj:
            counter += 1
        A[i], A[minj] = A[minj], A[i]
        i += 1

    print(" ".join(map(str, A)), counter, sep="\n")
selectionSort(A, N)


Measured memory_bytes: 5604
import itertools

n = int(input())
lst = []
for i in range(n):
    ai = int(input())
    lsti = []
    for j in range(ai):
        xj, yj = map(int, input().split())
        xj -= 1
        lsti.append([xj, yj])
    lst.append(lsti)

ans = 0
for v in itertools.product([0, 1], repeat=n):
    ok = 1
    for i in range(n):
        if v[i] == 0: continue
        if ok == 0: break
        lsti = lst[i]
        for xj, yj in lsti:
            if v[xj] != yj:
                ok = 0
                break
    if ok == 1:
        ans = max(ans, sum(v))

print(ans)

Measured memory_bytes: 42480