akhauriyash/Code-Regression huggingface dataset:
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <math.h>
# include <time.h>
# include <algorithm>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define MAXN 250
# define eps 1e-3
# define MAXM 500005
# define MOD 1000000007
# define INF 1000000000
# define MIN(a,b) (a)>(b)?(b):(a)
# define MAX(a,b) (a)<(b)?(b):(a)
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
# define bug puts("H");
typedef long long LL;
typedef unsigned long long ULL;


int main()
{
    long long a,b;
    cin>>a>>b;
    if(a==b)cout<<"Brown"<<endl;
    else if(a==0&&b==1)cout<<"Brown"<<endl;
    else if(a==1&&b==0)cout<<"Brown"<<endl;
    else if(a==2&&b==1)cout<<"Brown"<<endl;
    else if(a==1&&b==2)cout<<"Brown"<<endl;
    else if(a-b==1||b-a==1)cout<<"Brown"<<endl;
    
    else cout<<"Alice"<<endl;
    return 0;
}





















Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)
ll INF = 1LL << 60;
void solve(long long N, std::vector<long long> a){
    ll ans = 0;
    rep(i, N)
        ans += a[i]-1;
    cout << ans << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
const int MAXN = 100000 + 5;
int n, K, h[MAXN], f[MAXN];
int main() {
  scanf("%d%d", &n, &K);
  for (int i = 0; i < n; i++) scanf("%d", h + i);
  for (int i = 1; i < n; i++) {
    f[i] = 0x7fffffff;
    for (int j = i - 1, k = 1; j >= 0 && k <= K; j--, k++) {
      f[i] = min(f[i], f[j] + abs(h[j] - h[i]));
    }
  }
  printf("%d\n", f[n - 1]);
  return 0;
}

Measured memory_bytes: 896
/**
 * Author: Behradm
 * Created: 02-05-2020 16:44:19
 * In the Name of God
**/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;

#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define LOCAL

#ifdef LOCAL
	#define debugi(x) cerr << "{" << #x << "}: " << (x) << '\n'
	#define debug(v, begin, end) cerr << "{ | "; for(auto i = begin; i < end; i++){cerr << #v << "[" << i << "]: " << v[i] << " | ";} cerr << " }\n"
	#define debugp(a, b) cerr << "\n{ " << a << " " << b << " }\n"
#else
	#define debugi(x) 42
	#define debug(v, begin, end) 42
	#define debugp(a, b) 42 
#endif

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	cout.tie(0);
	cout.precision(6);
	ll x, res = 0;
	cin >> x;
	ll t = 100;
	while (t < x){
		t += 0.01 * t;
		res++;
	}

	cout << res << '\n';
	return 0;
}



Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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 ctoi(char c){return c-'0';}

// TODO: write
int main() {
  ll n;cin>>n;
  vector<ll> a(n);rep(i,n)cin>>a[i];
  ll kabu = 0;
  ll price = INF;
  ll money = 1000;
  rep(i,n){
    if(a[i] > price){
      money -= kabu*price;
      money += a[i] * kabu;
    }
    kabu = money / a[i];
    price = a[i];
  }
  print(money);
  return 0;
}

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

int main()
{
	int A1, A2, A3;
	cin >> A1 >> A2 >> A3;

	string ans = "win";
	if( A1 + A2 + A3 >= 22 ) ans = "bust";

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;
#define rep(i,n) for(int i=0;i<(int) n;i++)
#define For(i,m,n) for(int i=(int) m;i<(int) n;i++)
#define fix(n) cout << fixed << setprecision((int)n)
int N;

int main() {
    cin >> N;
    int count=0;
    count+=(N/500)*1000+((N%500)/5)*5;
    cout << count << endl;
}

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

int main(){
    int n;
    cin>>n;
    vector<ll>t(n),a(n);
    rep(i,n)cin>>t[i]>>a[i];
    rep(i,n-1){
        ll mx=max((t[i]+t[i+1]-1)/t[i+1],(a[i]+a[i+1]-1)/a[i+1]);
        t[i+1]*=mx,a[i+1]*=mx;
    }
    cout<<t[n-1]+a[n-1]<<endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <math.h>
using namespace std;
int main(){
	int a,d,n;
	while(cin>>a>>d>>n){
		if(a==0) break;
		int ct=0,m=-1;
		while(ct<n){
			m++;
			int i=a+d*m;
			ct++;
			if(i>2&&i%2==0){
				ct--;
			}
			else if(i>3&&i%3==0){
				ct--;
			}
			else if(i>5&&i%5==0){
				ct--;
			}
			else if(i>7&&i%7==0){
				ct--;
			}
			else{
				for(int k=1;k<sqrt(i)+3;k++){
					if(i>71&&i%(6*k-1)==0){
						ct--;
						goto end;
					}
					else if(i>73&&i%(6*k+1)==0){
						ct--;
						goto end;
					}
				}
				if(i==1) ct--;
			}
			end:;
		}
		cout<<a+d*m<<endl;
	}
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    vl a(5);
    rep(i, 5) cin >> a[i];
    
    rep(i,5){
        if(a[i]==0){
            cout << i + 1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//CODE


void solve(void)
{
  int A,B,C;
  cin>>A>>B>>C;
  int X = C - A - B;

  if(4*A*B < X*X && X >= 0)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>

using namespace std;

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

int main(){
    deque<int> prime;
    prime.push_back(2);
    prime.push_back(3);
    for(int i=5;prime.size()<1000;i+=2){
        bool ok = true;
        for(auto& t : prime) if(i%t == 0) ok = false;
        if(ok) prime.push_back(i);
    }
    vector<int> p1, p2;
    for(int i=0;i<250;i++){
        p1.push_back(prime.front());
        prime.pop_front();
        p1.push_back(prime.back());
        prime.pop_back();
        p2.push_back(prime.front());
        prime.pop_front();
        p2.push_back(prime.back());
        prime.pop_back();
    }
    vector<vector<long long>> m(500, vector<long long>(500, 1));
    int v = 0;
    for(int i=0;i<500;i++){
        for(int j=0;j<500;j++){
            if((i+j)%2) continue;
            m[i][j] = p1[(i+j)/2] * p2[(j-i+498)/2];
            v = max(v, (i+j)/2);
            v = max(v, (j-i+498)/2);
        }
    }
    for(int i=0;i<500;i++){
        for(int j=0;j<500;j++){
            if((i+j)%2 == 0) continue;
            int dx[] = {-1, 0, 1, 0};
            int dy[] = {0, -1, 0, 1};
            for(int d=0;d<4;d++){
                int nx = i+dx[d];
                int ny = j+dy[d];
                if(nx < 0 || 500 <= nx || ny < 0 || 500 <= ny) continue;
                m[i][j] = lcm(m[i][j], m[nx][ny]);
            }
            ++m[i][j];
        }
    }
    int N; cin >> N;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++) cout << m[i][j] << " ";
        cout << endl;
    }

}

Measured memory_bytes: 5120
#include<iostream>
using namespace std;
int main(){

	int a,b,c,d,e,j,i;
	cin>>a>>b>>c>>d;

	e=a+b+c+d;
	j=e/60;
	i=e-(j*60);

	cout<<j<<endl;
	cout<<i<<endl;

	return 0;
	}


Measured memory_bytes: 3056
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long A, B;
	cin >> A >> B;
	long long ans = 0;
	long long num = B - A + 1;
	if (1 == A%2) {
		ans = A;
		A++;
		num--;
	}
	if (0 == num%4) {
		ans = ans xor 0;
	}
	else if (1 == num%4) {
		ans = ans xor 0;
		ans = ans xor B;
	}
	else if (2 == num%4) {
		ans = ans xor 0;
		ans = ans xor B;
		ans = ans xor (B - 1);
	}
	else {
		ans = ans xor 0;
		ans = ans xor B;
		ans = ans xor (B - 1); 
		ans = ans xor (B - 2);
	}
	cout << ans << endl;
	return 0;
}

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


int main() {
	int D;
	cin >> D;
	if (D == 24) {
		cout << "Christmas Eve\n";
	}
	else if (D == 25) {
		cout << "Christmas\n";
	}
	else if (D == 23) {
		cout << "Christmas Eve Eve\n";

	}
	else  {
		cout << "Christmas Eve Eve Eve\n";
	}
	cout << "\n";



	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <complex>
#include <cassert>
#include <random>
#include <cstring>
#include <numeric>
#define ll long long
#define ld long double
#define null NULL
#define all(a) a.begin(), a.end()
#define forn(i, n) for (int i = 0; i < n; ++i)
#define sz(a) (int)a.size()
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
template<class T> int gmax(T &a, T b) { if (b > a) { a = b; return 1; } return 0; }
template<class T> int gmin(T &a, T b) { if (b < a) { a = b; return 1; } return 0; }
using namespace std;

int main() {
    int x, y;
    while(~scanf("%d %d", &x, &y)) {
        if(x == y) printf("%d\n", 2 * x);
        else printf("%d\n", max(x, y) * 2 - 1);
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define per(i,n,j) for(int i=(n);i>=(j);i--)
using ll=long long;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF=1LL<<60;

int n;

int main(){
    cin>>n;
    map<ll,ll> cnt;
    rep(i,0,n){
        ll a;
        cin>>a;
        cnt[-a]++;
    }
    ll ans=1;
    int f=0;
    auto begin=cnt.begin(),end=cnt.end();
    for(auto itr=begin;itr!=end;itr++){
        if(f==2) break;
        if(itr->second > 1){
            if(f==0 && itr->second >=4){
                ans=itr->first*itr->first;
                f=2;
            }
            else{
                ans*=itr->first;
                f++;
            }
        }
    }
    if(f==2) cout<<ans<<"\n";
    else cout<<0<<"\n";
    return 0;
}


Measured memory_bytes: 9756
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n); for (int i = 0; i < (int)(n); i++)
vector<int> input(int N) {
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  return vec;
}

int main() {
  int x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  cout << x2+y1-y2 << " " << y2-x1+x2 << " " << x1+y1-y2 << " " << y1-x1+x2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define FILL(i,n) memset(i,n,sizeof(i));
#define X first
#define Y second
#define pb push_back
#ifdef brian
#define  debug(...) do{\
    fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename t> void _do(t &&x){cerr<<x<<endl;}
template<typename t,typename ...T> void _do(t &&x,T &&...tail){cerr<<x<<", ";_do(tail...);}
#else
#define debug(...)
#endif // brian

const ll INF=ll(1e15);
const ll MAXn=100005;

ll n;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n;
    ll k=n/11;
    if(n%11>6)cout<<k*2+2<<endl;
    else if(n%11==0)cout<<k*2<<endl;
    else cout<<k*2+1<<endl;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC128
{
	class Program
	{
		static void Main(string[] args)
		{
			var N = int.Parse(Console.ReadLine());
			var SP = ReadLines(N).ToList()
						.Select(x => x.Split(' '))
						.Select((x, i) => new { s = x[0], p = int.Parse(x[1]), i = i + 1 })
						.OrderByDescending(x => x.p)
						.OrderBy(x => x.s)
						.Select(x => x.i);
			WriteLines(SP);
		}

		static IEnumerable<string> ReadLines(int n)
		{
			foreach (var _ in Enumerable.Range(0, n))
			{
				yield return Console.ReadLine();
			}
		}

		static void WriteLines<T>(IEnumerable<T> obj)
		{
			foreach (var x in obj)
			{
				Console.WriteLine(x);
			}
		}
	}
}


Measured memory_bytes: 13792
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<i32>();
    let b=read::<i32>();
    let c=read::<i32>();
    println!("{}",
    if a==b{
    	if b==c{1}
        else{2}
    }else if b==c{2}
    else if a==c{2}
    else{3})
}

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

int main(){
	string s; cin>>s;
	int n=s.size();
	int flg=1;
	for(int i=0; i<n; i+=2){
		string a=s.substr(i,2);
		if(flg&&a=="hi") flg=1;
		else flg=0;
	}
	cout<<(flg?"Yes":"No")<<endl;
}

Measured memory_bytes: 3628
N,X = map(int,input().split())

a,p = [1],[1]
for i in range(N):
    a.append(a[i]*2 + 3)
    p.append(p[i]*2 + 1)

def calc(n,x):
    if n==0:
        if x <= 0:
            return 0
        else:
            return 1
    elif x <= 1 + a[n-1]:
        return calc(n-1,x-1)
    else:
        return p[n-1] + 1 + calc(n-1,x-2-a[n-1])

print(calc(N,X))

Measured memory_bytes: 3064
//G题，难点在于如何O(n)求出1个数大于0个数，可用前缀和或者树状数组等维护 
//复杂度O(n log(10^9)^2)，虽然log都是真log但常数很小，可以来个离散化把10^9优化成n 
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
long long n;//long long 警告 
int read()
{
	int x=0;char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x;
}
int a[100002],l=0x7fffffff,r;
void init()
{
	n=read();
	for(int i=1;i<=n;i++)
	{
		a[i]=read();
		l=min(l,a[i]);
		r=max(r,a[i]);
	}
}
int c[100002];//int数组比bool数组调试的时候好看 
int sum;
int lowbit(int x)
{
	return x&(-x);
}
int tr[1000002];
int add(int x)
{
	for(int i=x;i<=1000000;i+=lowbit(i))
	tr[i]++;
}
int ask(int x)
{
	int ans=0;
	for(int i=x;i;i-=lowbit(i))
	ans+=tr[i];
	return ans;
}
bool check(int x)
{
	for(int i=1;i<=n;i++)
	{
		if(a[i]>=x) c[i]=1;
		else c[i]=-1;
	}
	sum=-200000;
	long long ans=0;
	for(int i=1;i<=n;i++)
	{
		add(-sum); 
		sum+=c[i];//sum每次变化的abs=1，所以插入排序效率一般会很高（O(1),但如果卡可以卡到O(n/4))，但是难写（需要使用链表维护啥的，还要维护多少个数小于指针）…… 
		ans+=i-ask(-sum-1);
	}
	if((ans<<2)>=n*(n+1)) return true;
	else return false;
//	也可用另一种做法   https://www.cnblogs.com/henry-1202/p/9537952.html 
}
void play()
{
	int mid;
	while(l<r)
	{
		memset(tr,0,sizeof(tr));
		mid=(l+r+1)>>1;
		if(check(mid)) l=mid;
		else r=mid-1;
	}
	cout<<l<<endl;
}
int main()
{
	init();
	play();
	return 0;
} 

Measured memory_bytes: 4992
#include <iostream>
using namespace std;
int main(void){
    int H,W;
    while(true){
        cin >> H >> W;
        if(H==0 && W==0){
            break;
        }
        for (int j= 0; j<W; j++ ){
            cout << '#';
        }
        cout << endl;
        for(int i=1;i<H-1;i++){
            cout <<'#';
            for(int j=1;j<W-1;j++){
                cout << '.';
            }
            cout << '#' << endl;
        }
        for(int j=0;j<W;j++){
            cout << '#';
        }
        cout << endl << endl;
    }
}



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

int main() {
    int n;
    cin >> n;
    map<string,int> mp;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<bits/stdc++.h>
#include<climits>
#include<math.h>

#define forn(x,n,s) for(int i = x; i < n; i += s )
#define forr(x,n,s) for(int i = x; i>=n; i -= s)
#define PI 3.14159265358979323846264338327950L

using namespace std;

void go(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  #ifndef ONLINE_JUDGE
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
  #endif
} 
long long int mod = 1e9+7;

int main(){
    go(); 

    // code here
    int a,b,h,m;cin>>a>>b>>h>>m;
    long double angle = 2 * PI * ((long double)h/12.0 + ((long double)m/60.0)/12.0 - (long double)m/60.0);
    long double ans = (long double)(a*a + b*b) - (long double)( 2 * a * b * cosl(angle));
    cout << std::fixed;
    cout << std::setprecision(20);
    cout<<sqrtl(ans);
}






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

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

    int n,l;
    cin>>n>>l;
    vector<string>v;
    string s;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        v.push_back(s);
    }
    sort(v.begin(),v.end());
    for(string x:v)
        cout<<x;
    cout<<"\n";
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pic = pair<int, char>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int h,w;//y,x
bool inside(int y, int x)
{
    return (0<=y && y<h && 0<=x && x<w);
}
int cx[2010][2010];
int cy[2010][2010];

int main(){
    ll ans=0;
    cin>>h>>w;
    vector<string> s(h);
    for (int i = 0; i < h; i++)
    {
        cin>>s[i];
    }
    m0(cx);
    m0(cy);
    //x houkou
    for (int y = 0; y < h; y++)
    {
        int cnt=0,bgn=0;
        for (int x = 0; x < w; x++)
        {
            if(s[y][x]=='.')
            {
                cnt++;
                if(x==w-1)
                {
                    for (int xi = bgn; xi <= x; xi++)
                    {
                        cx[y][xi]=cnt;
                    }
                }
            }
            else //#
            {
                for (int xi = bgn; xi < x; xi++)
                {
                    cx[y][xi]=cnt;
                }
                cnt=0;
                bgn=x+1;
            }
        }
    }

    //y houkou
    for (int x = 0; x < w; x++)
    {
        int cnt=0,bgn=0;
        for (int y = 0; y < h; y++)
        {
            if(s[y][x]=='.')
            {
                cnt++;
                if(y==h-1)
                {
                    for (int yi = bgn; yi <= y; yi++)
                    {
                        cy[yi][x]=cnt;
                    }
                }
            }
            else //#
            {
                for (int yi = bgn; yi <= y; yi++)
                {
                    cy[yi][x]=cnt;
                }
                cnt=0;
                bgn=y+1;
            }
        }
    }
    
    //calc ans
    for (int y = 0; y < h; y++)
    {
        for (int x = 0; x < w; x++)
        {
            ll tmp = cx[y][x]+cy[y][x]-1;
            ans=max(ans,tmp);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 35968
g1 = %w(1 3 5 7 8 10 12)
g2 = %w(4 6 9 11)
g3 = %w(2)

x, y = gets.split

if g1.include?(x) && g1.include?(y) || g2.include?(x) && g2.include?(y) || g3.include?(x) && g3.include?(y)
  puts 'Yes'
else
  puts 'No'
end

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

typedef long long int ll;
typedef long double ld;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define MOD (ll)(1e9 + 7)
#define vi vector<int>
#define vii vector<vector<int> >
#define vl vector<ll>
#define vll vector<vector<ll> >
#define vc(T, nm) vector<T> nm
#define pb push_back
#define popb pop_back
#define si set<int>
#define sl set<ll>
#define F first
#define S second
#define pii pair<int, int>
#define mp make_pair
#define ins insert
#define ers erase
#define endl "\n"
#define mul(a, b) ((a % MOD) * (b % MOD)) % MOD
#define adr(a, b) ((a % MOD) + (b % MOD)) % MOD
#define FORA(x, s, e, inc) for(ll x = s; x != e; x += inc)
#define ROFA(x, s, e, inc) for(ll x = s; x != e; x -= inc)
#define FOR(x, s, e) FORA(x, s, e, 1)
#define ROF(x, s, e) ROFA(x, s, e, 1)
#define loop(x, n) FOR(x, 0, n)
#define rd1(t, a) 					t a; cin >> a;
#define rd2(t, a, b) 				rd1(t, a); rd1(t, b); 
#define rd3(t, a, b, c) 			rd2(t, a, b); rd1(t, c);
#define rd4(t, a, b, c, d) 			rd3(t, a, b, c); rd1(t, d);
#define rd5(t, a, b, c, d, e) 		rd4(t, a, b, c, d); rd1(t, e);
#define rd6(t, a, b, c, d, e, f) 	rd5(t, a, b, c, d, e); rd1(t, f);
#define rdA(t, nm, len)				t nm[len]; loop(i, len) {cin >> nm[i];}
#ifdef DEBUG
	#define deb(v) cout << endl << #v << ": " << v << endl
	#define db1(v) cout << endl << #v << ": " << "[ "; for(auto x: v) {cout << x << " ";}; cout << "]" << endl;
	#define db2(v) cout << endl << #v << ": " << endl; for(auto r: v) {cout << "[ "; for(auto x: r) {cout << x << " ";}; cout << "]" << endl;};
	#define dbl cout << "-------------------------------" << endl
#else
	#define deb(v)
	#define db1(v)
	#define db2(v)
	#define dbl
#endif

void solve() {
	rd5(ll, h1, m1, h2, m2, k);
	
	ll mnc = 0;
	while(h2 != h1 or m1 != m2) {
	    if(m1 < 59) {
	        m1++;
	    } else {
	        h1++;
	        m1 = 0;
	    }
	    mnc++;
	}
	
	cout << mnc - k << endl;
}

int main() {
	
	fastio;

// 	rd1(ll, t);
	ll t = 1;

    while(t--) {
        solve();
    }
    
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
// #include<bits/stdc++.h>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
	int N;
	string S;
	cin >> N >> S;

	long long R_count = 0;
	long long G_count = 0;
	long long B_count = 0;
	for (int i = 0; i < N; i++)
	{
		if (S[i] == 'R')
		{
			R_count += 1;
		}
		if (S[i] == 'G')
		{
			G_count += 1;
		}
		if (S[i] == 'B')
		{
			B_count += 1;
		}
	}

	long long minus = 0;
	for (int i = 0; i < N-2; i++)
	{
		for (int j = i+1; j < N-1; j++)
		{
			int k = 2 * j - i;
			if (k < N) {
				if (S[i] == S[j]) continue;
				if (S[i] == S[k]) continue;
				if (S[k] == S[j]) continue;
				minus += 1;
			}
		}
	}

//	for(int j = 0; j < N; j++) {
//		for(int i = 0; i < j; i++) {
//			int k = j + j - i;
//			if (k < N) {
//				if (S[i] == S[j]) continue;
//				if (S[i] == S[k]) continue;
//				if (S[k] == S[j]) continue;
//				minus += 1;
//			}
//		}
//	}
	long long r = R_count * G_count * B_count;

	cout << (r - minus) << endl;
}


Measured memory_bytes: 3196
# coding: utf-8
N = int(input())
A = [int(x) for x in input().split()]

L = dict(); R = dict()
for i in range(N):
    L[i + A[i]] = L.get(i + A[i], 0) + 1
    R[i - A[i]] = R.get(i - A[i], 0) + 1

ans = 0
# i + A[i] >= 2, i - A[i] <= N
for i in range(N):
    ans += L.get(i, 0) * R.get(i, 0)

print(ans)

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

int main(){
  int N,sum=0;
  cin>>N;
  vector<int> d(N);
  for(int i=0; i<N; i++){
    cin>>d.at(i);
  }
  for(int i=0; i<N; i++){
    for(int j=i+1; j<N; j++){
      sum+=d.at(i)*d.at(j);
    }
  }
  cout<<sum<<endl;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N;
  cin >> N;
  VL xs(N*3);
  REP(i,N*3) cin >> xs[i];

  VL mx(3*N+1), mn(3*N+1);
  {  
	priority_queue<LL,VL,greater<LL>> pqm;
	LL acc = 0;
	REP(i,N){
	  pqm.push(xs[i]);
	  acc += xs[i];
	}
	mx[N] = acc;
	FOR(i,N,3*N){
	  acc -= pqm.top();
	  acc += xs[i];
	  pqm.pop();
	  pqm.push(xs[i]);
	  mx[i+1] = max(mx[i], acc);
	}
  }

  {
	priority_queue<LL,VL,less<LL>> pqmx;
	LL acc = 0;
	REP(i,N){
	  pqmx.push(xs[3*N-1-i]);
	  acc += xs[3*N-1-i];
	}
	mn[2*N] = acc;
	for(int i=2*N-1;i>=0;--i){
	  acc -= pqmx.top();
	  acc += xs[i];
	  pqmx.pop();
	  pqmx.push(xs[i]);
	  mn[i] = min(mn[i+1], acc);
	}
  }
  
  LL ans = -1e18;
  FOR(i,N,2*N+1){
	maxi(ans, mx[i] - mn[i]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 9072
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		sc.close();

		System.out.println(z + " " + x + " " + y);
	}
}


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

double get(long long x)
{
	long long lx = x, nowans = 0;
	while(x)
	{
		nowans += x % 10;
		x /= 10;
	}
	return 1. * lx / nowans;
}
 
int main()
{
	int K;
	scanf("%d", &K);
	long long now = 0, delta = 1;
	for(int i = 1; i <= K; i++)
	{
		if(get(now + delta) > get(now + delta * 10))delta *= 10;
		now += delta;
		printf("%lld\n", now);
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

int main() {
    ll N, M;
    cin >> N >> M;
    vector<pll> v(N);
    for(int i = 0; i < N; i++) cin >> v[i].first >> v[i].second;

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

    ll ans = 0;
    for(int i = 0; i < N; i++) {
        if(M - v[i].second >= 0) {
            M -= v[i].second;
            ans += v[i].second * v[i].first;
        } else {
            ans += M * v[i].first;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(llong i = 0;i < n;i++)
#define REPR(i, n) for(llong i = n;i >= 1;i--)
#define FOR(i, m, n) for(llong i = m;i < n;i++)
#define FORR(i, m, n) for(llog i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
llong mod = 1000000007;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};


int main(){
  llong a;cin>>a;
  llong b;cin>>b;
  llong c;cin>>c;
  if(( b - a ) == ( c -b))cout << "YES"<<endl;
  else cout <<"NO"<<endl;
}
 

Measured memory_bytes: 256
from collections import deque
h, w, k = map(int, input().split())
y1, x1, y2, x2 = map(int, input().split())
c = []
for _ in range(h):
    c.append(input())
q = deque([(x1-1, y1-1)])
dxdy = [(-1,0), (0,-1), (0,1), (1,0)]
dist = [[1000000]*w for _ in range(h)]
dist[y1-1][x1-1] = 0
while q:
    x, y = q.popleft()
    for ddx, ddy in dxdy:
        for i in range(1, k+1):
            dx = ddx*i
            dy = ddy*i
            if not (0<=x+dx<w and 0<=y+dy<h):
                break
            if c[y+dy][x+dx]=='@' or dist[y+dy][x+dx]<=dist[y][x]:
                break
            if x+dx==x2-1 and y+dy==y2-1:
                print(dist[y][x]+1)
                exit(0)
            if dist[y+dy][x+dx]>dist[y][x]+1:
                dist[y+dy][x+dx] = dist[y][x]+1
                q.append((x+dx, y+dy))
print(-1)

Measured memory_bytes: 36772
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
  
  if((a==1 && b==2) || (a==2 && b==1)){
    printf("3");
  }
    else if((a==1 && b==3) || (a==3 && b==1)){
      printf("2");
    }
else
  printf("1");
  
  return 0;
}

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

int a, b, c, d;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> a >> b >> c >> d;
	if(abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d)) cout << "Yes\n";
	else cout << "No\n";
}

Measured memory_bytes: 256
#include <cstdio>

const int mod = 998244353, inv2 = 499122177;
const int MAXN = 20, MAXL = ( 1 << 18 ) + 5;

template<typename _T>
void read( _T &x )
{
	x = 0;char s = getchar();int f = 1;
	while( s > '9' || s < '0' ){if( s == '-' ) f = -1; s = getchar();}
	while( s >= '0' && s <= '9' ){x = ( x << 3 ) + ( x << 1 ) + ( s - '0' ), s = getchar();}
	x *= f;
}

template<typename _T>
void write( _T x )
{
	if( x < 0 ){ putchar( '-' ); x = ( ~ x ) + 1; }
	if( 9 < x ){ write( x / 10 ); }
	putchar( x % 10 + '0' );
}

int F[MAXL], p[MAXL], h[MAXL];
int N, len;

int qkpow( int base, int indx )
{
	int ret = 1;
	while( indx )
	{
		if( indx & 1 ) ret = 1ll * ret * base % mod;
		base = 1ll * base * base % mod, indx >>= 1;
	}
	return ret;
}

int inv( const int a ) { return qkpow( a, mod - 2 ); }
int fix( const int x ) { return ( x % mod + mod ) % mod; }

void FWT( int *f, const int mode )
{
	int t1, t2;
	for( int s = 2 ; s <= len ; s <<= 1 )
		for( int i = 0, t = s >> 1 ; i < len ; i += s )
			for( int j = i ; j < i + t ; j ++ )
			{
				t1 = f[j], t2 = f[j + t];
				if( mode > 0 ) f[j] = ( t1 + t2 ) % mod, f[j + t] = fix( t1 - t2 );
				else f[j] = 1ll * ( t1 + t2 ) * inv2 % mod, f[j + t] = 1ll * fix( t1 - t2 ) * inv2 % mod;
			}
}

int main()
{
	int s = 0;
	read( N ); len = 1 << N;
	for( int i = 0 ; i < len ; i ++ ) read( p[i] ), s = ( s + p[i] ) % mod;
	s = inv( s );
	for( int i = 0 ; i < len ; i ++ ) p[i] = 1ll * p[i] * s % mod;
	for( int i = 1 ; i < len ; i ++ ) h[i] = mod - 1;
	h[0] = len - 1, p[0] = fix( p[0] - 1 );
	FWT( h, 1 ), FWT( p, 1 );
	for( int i = 1 ; i < len ; i ++ ) F[i] = 1ll * h[i] * inv( p[i] ) % mod;
	FWT( F, -1 );
	int tmp = mod - F[0];
	for( int i = 0 ; i < len ; i ++ ) write( ( tmp + F[i] ) % mod ), putchar( '\n' );
	return 0;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int a, b, c, k;
  cin >> a >> b >> c >> k;
  if(k&1) cout << b-a << endl;
  else cout << a-b << endl;

  return 0;
}


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

int main() {

	ll n; cin >> n;
	const ll p = 26;
	ll tmp = n;
	string ans = "";
	while (true) {
		tmp--;
		ll tmpMod = tmp % p;
		char tmpChar = (char)('a' + tmpMod);
		string tmpChar_s{ tmpChar };
		ans += tmpChar_s;
		if (tmp / p == 0) break;
		tmp /= p;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3604
import string
n=int(input())
s=list(input())
cnt=[0 for i in range(n-1)]
for i in range(n-1):
    for j in string.ascii_lowercase:
        if (j in s[:i+1] and j in s[i+1:]): cnt[i]+=1
print('{0}'.format(max(cnt)))

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

int main(void){
	char str[201];		// input; card line, size>=200
	int m=0;			// input; shuffle times, size>=100
	int h=0, sum_h=0;	// input; shuffle height, sum_h:finally shuffle height
	int i=0;			// loop index;
	char* p_str = str;	// str pointer
	char cpy[201];
	char* p_cpy = cpy;	// cpy pointer	
	char ans[201];


	scanf("%s", str);
	while(strcmp(str, "-") != 0){
		scanf("%d", &m);
		sum_h = 0;

		for(i=0;i<m;i++){
			scanf("%d", &h);
			sum_h += h;
		}

		h = sum_h % strlen(str);

		if(h == 0) printf("%s\n", str);
		else{
			strncpy(cpy, str, h);
			*(p_cpy + h) = '\0';
			strcpy(ans, p_str+h);
			strcat(ans, cpy);

			printf("%s\n", ans);
		}
		scanf("%s", str);
	}
	
	return 0;
}

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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define dbg(x) cout<<#x<<"="<<x<<endl

typedef long long ll;

#define fi first
#define se second

#define X real()
#define Y imag()

struct FFT {
  using C = complex<double>;
  const double PI = acos(-1);
  vector< vector<C> > rts,rrts;

  void DFT(vector<C>& F, bool rev){
    int N=(int)F.size();
    auto &r = rev?rrts:rts;

    for(int i=0,j=1;j+1<N;j++){
      for(int k=(N>>1);k>(i^=k);k>>=1);
      if(i>j)swap(F[i],F[j]);
    }
    if(rts.size()<N){
      rts.resize(N); rrts.resize(N);

      for(int i=1;i<N;i<<=1){
        if(rts[i].size()) continue;
        rts[i].resize(i), rrts[i].resize(i);

        for(int k=0;k<i;k++){
          rts[i][k]=polar(1.0,PI/i*k);
          rrts[i][k]=polar(1.0,-PI/i*k);
        }
      }
    }

    C s,t;
    for(int i=1;i<N;i<<=1){
      for(int j=0;j<N;j+=i*2){
        for(int k=0;k<i;k++){
          s=F[j+k];
          t=C(F[j+k+i].X*r[i][k].X-F[j+k+i].Y*r[i][k].Y,
              F[j+k+i].X*r[i][k].Y+F[j+k+i].Y*r[i][k].X);
          F[j+k]=s+t;
          F[j+k+i]=s-t;
        }
      }
    }
    if(rev)for(int i=0;i<N;i++)F[i]/=N;
  }

  vector<ll> Multiply(const vector<int>& A,const vector<int>& B){
    int sz=1;
    while(sz<A.size()+B.size()-1)sz<<=1;
    vector<C> F(sz),G(sz);
    for(int i=0;i<A.size();i++)F[i]=A[i];
    for(int i=0;i<B.size();i++)G[i]=B[i];

    DFT(F,false); DFT(G,false);

    for(int i=0;i<sz;i++) F[i]*=G[i];

    DFT(F,true);

    vector<ll> res(A.size()+B.size()-1);
    for(int i=0;i<A.size()+B.size()-1;i++)res[i]=(ll)(F[i].real()+0.5);

    return res;
  }
};

pair<int,int> dir(char c){
  if(c=='R')return pair<int,int>(0,+1);
  if(c=='U')return pair<int,int>(-1,0);
  if(c=='L')return pair<int,int>(0,-1);
  if(c=='D')return pair<int,int>(+1,0);
  return pair<int,int>(-1,-1);
}

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

  cin>>N>>M>>K>>L;
  vector<string> b(N);
  rep(i,N){
    cin>>b[i];
  }

  vector<int> A(3*M*M,0);

  string S;
  cin>>S;
  int crti=0,crtj=0;
  rep(i,L){
    pair<int,int> d=dir(S[i]);
    crti+=d.first;
    crtj+=d.second;

    A[crti*M+crtj]++;
  }

  vector<int> B(3*M*M,0);
  rep(i,N)rep(j,N){
    if(b[i][j]=='X'){
      B[i*M+j]=1;
    }
  }

  FFT fft;
  vector<ll> res=fft.Multiply(A,B);

  int ans=0;
  rep(i,res.size()){
    if(res[i]>=K)ans++;
  }
  cout<<ans<<endl;

  return 0;
}



Measured memory_bytes: 250740
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}


int main(){
  ll n;
  cin >> n;
  ll a[1000000];
  FOR(i,n){
    cin >> a[i];
  }
  ll sum=0,ans=0;
  FOR(i,n){
    sum+=a[i];
    if(i%2==0){
      if(sum<=0){
        ans+=1-sum;
        sum=1;
      }
    }else{
      if(sum>=0){
        ans+=sum+1;
        sum=-1;
      }
    }
  }
  ll ans2=0;
  sum=0;

  FOR(i,n){
    sum+=a[i];
    if(i%2==1){
      if(sum<=0){
        ans2+=1-sum;
        sum=1;
      }
    }else{
      if(sum>=0){
        ans2+=sum+1;
        sum=-1;
      }
    }
  }

  cout << min(ans,ans2) << endl;
  
}


Measured memory_bytes: 2944
#include <cstdio>
#include <iostream>
using namespace std;
int counta;
void judge(char d[][20], int x, int y, int limitx, int limity) {
	if (d[y][x] == '@' || d[y][x] == '.') {
		d[y][x] = '#';
		counta++;
		if (x > 0) judge(d, x - 1, y, limitx, limity);
		if (x <= limitx - 2)judge(d, x + 1, y, limitx, limity);
		if (y>0)judge(d, x, y - 1, limitx, limity);
		if (y <= limity-2)judge(d, x, y + 1, limitx, limity);
	}
}

int main() {
	int x, y;
	int manx = 0;
	int many = 0;
	do {

		counta = 0;
		char a[20][20];
		for (int i = 0; i < 20; i++) {
			for (int j = 0; j < 20; j++)
				a[i][j] = '#';
		}
		cin >> x >> y;
		if (x == 0)break;
		for (int i = 0; i < y; i++) {
			for (int j = 0; j < x; j++) {
				cin >> a[i][j];
				if (a[i][j] == '@') { many = i; manx = j; }
			}
		}
		judge(a, manx, many, x, y);
		cout << counta << "\n";

	} while (1);
}

Measured memory_bytes: 1180
#![allow(dead_code, unused_imports, deprecated)]
use std::cmp::{max, min, Reverse};
use std::collections::*;
use maplit::*;
use num::Integer;
use proconio::input;
use proconio::marker::*;
use proconio::fastout;

const INF : usize = 1000000007;

#[fastout]
fn main() {
  input! {
    n: usize, m: usize, k: usize,
  };
  input! {
    mut a: [usize; n],
    mut b: [usize; m],
  };
  
  a.insert(0, 0);
  b.insert(0, 0);

  for i in 1..=n {
    a[i] += a[i - 1];
  }
  for i in 1..=m {
    b[i] += b[i - 1];
  }
  
  let mut res = 0;
  let mut i = 0;
  let mut j = m;
  loop {
    if i > n || j < 0 || j > m { break; }
    
    if a[i] + b[j] > k {
      j -= 1;
      continue;
    } else {
      while i < n && a[i + 1] + b[j] <= k {
        i += 1;
      }
      
      res = max(res, i + j);
      i += 1;
    }
  }
  
  println!("{}", res);
}

Measured memory_bytes: 9460
//周期で殴ってみよう。
//行列累乗は間に合わないですね。
//でもkが大きいので、2^k単位でシミュレーションとかしないと無理. -> 漸化式が難しすぎるので、1回の更新を観察しよう ->
//a    b    c
//a  a+c-b  c
//これは、階差数列の交換操作になっている。
//つまり、M回の交換をK回繰り返せばよい。これは置換のダブリングでできる。(大きいあみだくじと同じ問題）
#include <iostream>
#define int long long
using namespace std;

int n;
int x[100000];
int m, k;
int a[100000];

signed main() {
	int i, j;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> x[i];
	cin >> m >> k;
	for (i = 0; i < m; i++) { cin >> a[i]; a[i]--; }
	
	//階差i = うさぎi+1の位置 - うさぎiの位置
	static int p[100000];	//p[i] = (1回の運動後の階差i == 最初の階差p[i])
	static int pp[70][100000];
	
	for (i = 0; i < n - 1; i++) { p[i] = i; }
	for (i = 0; i < m; i++) { swap(p[a[i] - 1], p[a[i]]); }
	
	for (i = 0; i < n - 1; i++) { pp[0][i] = p[i]; }
	
	for (i = 1; i < 62; i++) {
		static int u[100000];
		for (j = 0; j < n - 1; j++) { u[j] = pp[i-1][j]; }
		for (j = 0; j < n - 1; j++) { pp[i][j] = u[pp[i-1][j]]; }
	}
	
	static int finall[100000];
	for (i = 0; i < n - 1; i++) {
		finall[i] = i;
	}
	for (i = 61; i >= 0; i--) {
		static int tmp[100000];
		if ((k >> i) % 2 == 0) { continue; }
		
		//置換
		for (j = 0; j < n - 1; j++) { tmp[j] = finall[j]; }
		for (j = 0; j < n - 1; j++) { finall[j] = tmp[pp[i][j]]; }
	}
	
	//答える
	int ans = x[0];
	for (i = 0; i < n; i++) {
		cout << ans << endl;
		ans += x[finall[i] + 1] - x[finall[i]];
	}
	return 0;
}

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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}

const int NMAX=1e5;
/// tree con LCA procesamiento O(N log N) consultas O(log N)
struct tree {
    int N, timer, l,root;
    vector<vii> G;
//   vii children[NMAX];
    vvi up;
    vi tin,tout,level;
    tree(int n,int _root) : N(n),root(_root) {
        tin.resize(n),tout.resize(n),level.resize(n);
        up.resize(n),G.resize(n);
    };

    void add_edge(int a, int b, int w = 0) {
        G[a].push_back(MP(b, w));
        G[b].push_back(MP(a, w));
    }

    void build() {
        l = log2(N)+1;
        //   while((1 << l) <= N)  ++l;
        for(int i = 0; i < N; ++i) up[i].resize(l + 1);
        dfs(root,root);
    }

    void dfs(int node, int p,int lev=0) {
        tin[node] = ++timer;
        level[node]=lev++;
        up[node][0] = p;
        for(int i = 1; i <= l; ++i)
            up[node][i] = up[up[node][i - 1]][i - 1];
        for(auto c : G[node])
            if(c.first != p) dfs(c.first, node,lev);
        tout[node] = ++timer;
    }

    bool upper(int a, int b) {return tin[a] <= tin[b] && tout[a] >= tout[b];}

    int lca(int a, int b) {
        if(upper(a, b)) return a;
        if(upper(b, a)) return b;
        for(int i = l; i >= 0; --i)
            if(!upper(up[a][i], b))
                a = up[a][i];
        return up[a][0];
    }

    int dist(int u,int v){
        return abs(level[u]-level[v]);
    }
};


int main() {
    READ(1);
    int n,u,v;cin>>n>>u>>v;
    --u,--v;
    tree t(n,v);
    FOR(i,n-1){
        int x,y;cin>>x>>y;
        t.add_edge(x-1,y-1);
    }
    t.build();
    vi stock;
    for(int i=0;i<n;++i) if (t.tin[i]+1==t.tout[i]) stock.push_back(i);
    sort(stock.begin(),stock.end(),[&t](int x,int y){return t.level[x]>t.level[y];});
    for(int node:stock){
        int l=t.lca(node,u);
        int d1=t.dist(u,l);
        if (d1<t.level[l]) {
            cout << t.level[node]-1;
            return 0;
        }
    }
}



Measured memory_bytes: 20352
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int n, sum=0, i;
    scanf("%lld", &n);
    long long int A[n+1];
    long long int B[n];
    for(i=0; i<=n; i++)
        scanf("%lld", A+i);
    for(i=0; i<n; i++)
        scanf("%lld", B+i);
    for(i=0; i<n; i++)
    {
        if(B[i]>A[i])
        {
            sum=sum+A[i];
            B[i]=B[i]-A[i];
            if(B[i]>=A[i+1])
            {
                sum=sum+A[i+1];
                A[i+1]=0;
            }
            else
            {
                sum=sum+B[i];
                A[i+1]=A[i+1]-B[i];
            }
        }
        else
            sum=sum+B[i];
    }
    printf("%lld\n", sum);
    return 0;
}


Measured memory_bytes: 1792
import itertools

n = int(input())

xy = []
for _ in range(n):
    xy.append(list(map(int, input().split())))

total = 0

for x1, y1 in xy:
    for x2, y2 in xy:
        total += ((x1 - x2)**2 + (y1 - y2)**2)**(1/2)
    
print(total/n)

Measured memory_bytes: 3188