akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

#define EPS     1e-11
#define INF     0x7fffffff
#define LL_INF  0x7fffffffffffffff

typedef long long LL;
struct Point {
        int x, y;
};
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};


int main() {
    int a, b;
    cin >> a >> b;
    for (int c = 1; c <= 3; c++)
        if ((a*b*c)%2 == 1) {
            cout << "Yes" << endl;
            return 0;
        }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const ll P = 1e9+7;
int N;
string S1, S2;
ll x[60][9];

int main(){
	cin >> N >> S1 >> S2;

	/*
	 * 0: 0
	 * 1: 1
	 * 2: 2
	 * 3: 01
	 * 4: 02
	 * 5: 10
	 * 6: 12
	 * 7: 20
	 * 8: 21
	*/

	int i=0;
	if(S1[0] == S2[0]){
		for(int i=0; i<3; i++) x[0][i] = 1;
	}
	else{
		for(int i=3; i<9; i++) x[1][i] = 1;
		i++;
	}
	i++;


	while(i<N){
		if(S1[i] == S2[i]){
			x[i][0] = (x[i-1][1] + x[i-1][2] + x[i-1][6] + x[i-1][8])%P;
			x[i][1] = (x[i-1][2] + x[i-1][0] + x[i-1][4] + x[i-1][7])%P;
			x[i][2] = (x[i-1][0] + x[i-1][1] + x[i-1][3] + x[i-1][5])%P;
		}
		else{
			x[i+1][3] = (x[i-1][2] + x[i-1][5] + x[i-1][6] + x[i-1][7])%P;
			x[i+1][4] = (x[i-1][1] + x[i-1][5] + x[i-1][7] + x[i-1][8])%P;
			x[i+1][5] = (x[i-1][2] + x[i-1][3] + x[i-1][4] + x[i-1][8])%P;
			x[i+1][6] = (x[i-1][0] + x[i-1][3] + x[i-1][7] + x[i-1][8])%P;
			x[i+1][7] = (x[i-1][1] + x[i-1][3] + x[i-1][4] + x[i-1][6])%P;
			x[i+1][8] = (x[i-1][0] + x[i-1][4] + x[i-1][5] + x[i-1][6])%P;
			i++;
		}
		i++;
	}

	ll ans = 0;
	for(int i=0; i<9; i++) ans = (ans+x[N-1][i])%P;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
int a,b,c,d,e,g=0;
cin>>a>>b>>c>>d>>e;
if(a<0){
g+=(0-a)*c+d;
a=0;
}
g+=(b-a)*e;
cout<<g<<endl;
return 0;
}

Measured memory_bytes: 3112
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>
#include <bitset>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    int n;
    cin >> n;
    vll a(3 * n);
    rep(i, 3 * n) cin >> a[i];

    ll suml = 0, sumr = 0;
    multiset<ll> setl, setm, setr;
    rep(i, n) {
        setl.insert(a[i]);
        suml += a[i];
    }
    rep(i, 2 * n) {
        setm.insert(a[i + n]);
    }
    while(setm.size() > n) {
        ll _a = *setm.begin();
        sumr += _a;
        setr.insert(_a);
        setm.erase(setm.find(_a));
    }
    ll ans = suml - sumr;
    for(int i = n; i < 2 * n; ++i) {
        suml += a[i];
        setl.insert(a[i]);
        suml -= *setl.begin();
        setl.erase(setl.begin());
        if(a[i] >= *setm.begin()) {
            setm.erase(setm.find(a[i]));
        }
        else {
            sumr -= a[i];
            setr.erase(setr.find(a[i]));
            sumr += *setm.begin();
            setr.insert(*setm.begin());
            setm.erase(setm.begin());
        }
        chmax(ans, suml - sumr);
    }
    cout << ans << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
struct Edge {
    int to;
    int weight;
    Edge(int t, int w)
        : to(t)
        , weight(w)
    {
    }
};
using Graph = vector<vector<int>>;
using Graph_e = vector<vector<Edge>>;
typedef long long ll;
typedef pair<int, int> P;
vector<int> dx = { 1, 0, -1, 0 };
vector<int> dy = { 0, 1, 0, -1 };

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

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

struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank;

    UnionFind(int n = 1)
    {
        init(n);
    }

    void init(int n = 1)
    {
        par.resize(n);
        rank.resize(n);
        for (int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
        }
    }

    int root(int x)
    {
        if (par[x] == x) {
            return x;
        } else {
            int r = root(par[x]);
            return par[x] = r; // 辺の縮約（一度根をたどったら辺を直接根に向かって貼り直す）
        }
    }

    bool issame(int x, int y)
    {
        return root(x) == root(y);
    }

    bool merge(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        if (rank[x] < rank[y])
            swap(x, y);
        if (rank[x] == rank[y])
            ++rank[x];
        par[y] = x; // xよりyのほうが高さが小さい木
        return true;
    }
};

// 最大公約数
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}

// 最小公倍数
int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y)
{
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}

// 負の数にも対応した % 演算
long long mod(long long val, long long m)
{
    long long res = val % m;
    if (res < 0)
        res += m;
    return res;
}

// a^n modを計算する
long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    // nを2進数表示して1が埋まっている桁に関してはa^mをかけていく
    while (n > 0) {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod)
{
    return modpow(a, mod - 2, mod);
}

int main()
{
    int H, N;
    cin >> H >> N;
    vector<int> A(N);
    rep(i, N) cin >> A.at(i);

    rep(i, N)
    {
        H -= A.at(i);
    }
    if (H <= 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline

def main():
    while True:
        s = input().strip()
        if s[0] == "-":
            break
        N = int(input())
        for i in range(N):
            t = int(input())
            s = s[t:] + s[:t]
        print(s)


if __name__ == "__main__":
    main()


Measured memory_bytes: 5600
#include<iostream>
using namespace std;
#include<stdio.h>
int main(){
    
    int a,b,d,r;
    double f;
    cin>>a >>b;
    d = a/b;
    r = a%b;
    f = (double)a/(double)b;
    printf("%d %d %f.%.8lf", d, r, f );
    return 0;
    
}


Measured memory_bytes: 3188
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define fi first
#define se second
#define rep(i,N) for(int i=0;i<(int)N;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (waz - inv(waz % x) * (waz / x)) % waz;
        if (a >= 0) { return a; }
        else { return waz + a; }
    }
}

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<ll> p;

ll phi(ll x) {
    ll a = x;
    ll b = x;
    for (ll k = 0; k != p.size(); ++k) {
        if (a % p[k] == 0) {
            while (a % p[k] == 0) {
                a /= p[k];
            }
            b = b / p[k] * (p[k] - 1);
        }
        if (a == 1) { break; }
    }
    return b;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    IO;

    int N; cin >> N;
    vector<int> A(N), B(N-1);
    rep(i, N - 1) cin >> B[i];
    A[0] = B[0]; A[N - 1] = B[N - 2];
    if (N > 2) {
        for (int i = 1; i < N - 1; ++i) {
            A[i] = min(B[i], B[i - 1]);
        }
    }
    int ans = 0;
    rep(i, N) ans += A[i];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main()
{
	bool f=0;
	int a,b,i;
	string s1;
	cin>>s1;
	for(i=0;i<s1.size();i++)
	{
		if(s1[i]=='A'&&f==0)
		{
			a=i;
			f=1;
		}
		if(s1[i]=='Z')
		b=i;
	}
	cout<<b-a+1<<endl;
	return 0;
}

Measured memory_bytes: 640
h,w=map(int,input().split())
c=[list(map(int,input().split()))for _ in range(10)]
for i in range(10):
	for j in range(10):
		for k in range(10):c[j][k]=min(c[j][k],c[j][i]+c[i][k])
co=[c[i][1] for i in range(10)]
ans=0
for _ in range(h):
	for i in list(map(int,input().split())):
		if i!=-1:ans+=co[i]
print(ans)

Measured memory_bytes: 3064
n = int(input())
r = []
for i in range(n):
    t = input().split()
    t[1] = int(t[1])
    t.append(i+1)
    r.append(t)

r.sort(key=lambda _r: _r[1], reverse=True)
r.sort(key=lambda _r: _r[0])

for num in r:
    print(num[2])

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

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

struct UnionFind {
    vector<int> par;
    UnionFind(int N)
        : par(N)
    { //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++)
            par[i] = i;
    }
    int root(int x)
    {
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)
            return;
        par[rx] = ry;
    }
    bool same(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    UnionFind uf(n);
    vector<vector<int>> near(n);
    vector<vector<int>> block(n);
    REP(i,m){
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        uf.unite(a,b);
        near[a].push_back(b);
        near[b].push_back(a);
    }
    REP(i,k){
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        block[a].push_back(b);
        block[b].push_back(a);
    }
    map<int,int> mpii;
    REP(i,n){
        mpii[uf.root(i)]++;
    }

    REP(i,n){
        int ans=mpii[uf.root(i)]-near[i].size()-1;
        REP(j,block[i].size())
            if(uf.same(i,block[i][j]))
                ans--;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 15640
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef unordered_set<ll> uset;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=0;i<=n;i++)
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define all(x) x.begin(),x.end()
#pragma gcc optimize("O3")
#pragma gcc optimize("unroll-loops")
#pragma gcc target("avx2,see4")
#define INF 2147483647
typedef struct segtree{
	struct node{
		node *cl,*cr;
		int dat;
		node(){
			cl=NULL,cr=NULL,dat=INF;
		}
	};
	node root;
	ll siz;
	void init(int sizes){
		siz=sizes;
		root=node();
	}
	void eval(node *v,int a,int b){
		if(a+1<b){
			if(v->cl==NULL)v->cl=new node();
			if(v->cr==NULL)v->cr=new node();
		}
	}
	void upd(node *v,int a,int b,int L,int R,int val){
		if(b<=L||R<=a)return;
		if(L<=a&&b<=R){
			v->dat=val;
			return;
		}
		eval(v,a,b);
		int m=(a+b)>>1;
		upd(v->cl,a,m,L,R,val);
		upd(v->cr,m,b,L,R,val);
		v->dat=min(v->cl->dat,v->cr->dat);
	}
	void upd(ll L,ll R,ll val){
		upd(&root,0,siz,L,R,val);
	}
	ll qry(node *v,int a,int b,int L,int R){
		if(b<=L||R<=a)return INF;
		if(L<=a&&b<=R){
			return v->dat;
		}
		eval(v,a,b);
		int m=(a+b)>>1;
		ll vl=qry(v->cl,a,m,L,R);
		ll vr=qry(v->cr,m,b,L,R);
		return min(vl,vr);
	}
	ll qry(ll L,ll R){
		return qry(&root,0,siz,L,R);
	}
}segtree;
segtree seg;
int main(){
	seg.init(200010);
	ll n,q;
	cin>>n>>q;
	while(q--){
		bool com;
		ll x,y;
		cin>>com>>x>>y;
		if(com==0){
			seg.upd(x,x+1,y);
		}
		if(com==1){
			cout<<seg.qry(x,y+1)<<endl;
		}
	}
}



Measured memory_bytes: 8972
# coding:utf-8

cnt = input()
nums = list(map(int, input().split()))


def evens(arr):
    ans = [0 for i in arr if i % 2 == 1]
    return len(ans) == 0


cnt = 0
while evens(nums):
    for i, obj in enumerate(nums):
        nums[i] = obj / 2
    cnt += 1
print(cnt)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <climits>
#include <iomanip>
#define endl "\n"
#define debug(x) cout << #x << " : " << x << endl;
#define debug2(x, y) cout << #x << " : " << x  << ", " << #y << " : " << y << endl;
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0);
typedef long long ll;
using namespace std;

const ll infinite = 1e12;
ll dp[105][100010];
ll w[105];
ll v[105];

int main()
{
	FASTIO

	ll n, W;
	cin >> n >> W;

	for(ll i = 1; i <= n; i ++)
	{
		cin >> w[i] >> v[i];
	}

	// dp[x][y] stores Minimum weight we can get by first x elements having value v

	for(ll i = 0; i <= n; i ++)
	{
		for(ll j = 1; j <= 100000; j ++)
			dp[i][j] = infinite;
	}

 	dp[0][0] = 0;

	for(ll i = 1; i <= n; i ++)
	{
		for(ll j = 0; j <= 100000; j ++)
		{
			if(j >= v[i])
				dp[i][j] = min(dp[i - 1][j - v[i]] + w[i],dp[i - 1][j]);
			else
				dp[i][j] = dp[i - 1][j];
		}
	}

	for(ll i = 100000; i >= 0; i --)
	{
		if(dp[n][i] <= W)
		{
			cout << i << endl;
			break;
		}
	}	
}

Measured memory_bytes: 82564
#include <string>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm> 
using namespace std;

int main()
{
	string s;
	int f=0,n;
	cin>>n;
	cin>>s;
	if(n%2!=0)
	{
		f=1;
	}
	else
		for(int i=0;i<n/2;i++)
		{
			if(s[i]!=s[n/2+i])
			{
				f=1;
				break;
			}
		}
	if(f==1)
		cout<<"No";
	else
		cout<<"Yes";
		
	
	return 0;
}

Measured memory_bytes: 256
x[10];
main(n,a)
{
  for(;;)
  {
    for(n=10;n--;)x[n]=0;
    scanf("%d",&n);
    if(!n)exit(0);
    for(;n--;)
      {
	scanf("%d",&a);
	x[a]++;
      }
    for(n=0;n<10;n++)
      if(x[n]==0)
	puts("-");
      else
	{
	  for(a=x[n];a--;printf("*"));
	  puts("");
	}
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 2;
const int INF = 2e18;

signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    cin >> A;
    map<int, int> count, dif;
    int base = 0;
    for (int i = 0; i < N; i++) count[A[i]]++;
    for (auto itr = count.begin(); itr != count.end(); itr++) {
        int c = itr->second;
        dif[itr->first] = (c * (c - 1)) / 2;
        base += dif[itr->first];
    }
    for (int i = 0; i < N; i++) {
        int temp = count[A[i]] - 1;
        int minus = dif[A[i]] - (temp * (temp - 1)) / 2;
        cout << base - minus << endl;
    }

}


Measured memory_bytes: 18944
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int[] A = new int[S.length()];
    int i = 0;
    while (i < S.length()) {
      int iRL = S.indexOf("RL", i);
      int numR = iRL - i;
      int iNextR = S.indexOf("R", iRL + 2);
      if (iNextR == -1) {
        iNextR = S.length();
      }
      int numL = iNextR - (iRL + 2);

      // RL(ab)
      int a = 1 + numR / 2 + (numL+1) / 2;
      int b = 1 + (numR + 1) / 2 + numL / 2;
      for (int j = i; j < iRL; j++) {
        A[j] = 0;
      }
      A[iRL] = a;
      A[iRL+1] = b;
        
      for (int j = iRL+2; j < iNextR; j++) {
        A[j] = 0;
      }
      
      // next
      i = iNextR;
    }
    for (int j = 0; j < A.length; j++) {
      System.out.print(A[j] + " ");
    }
  }  
}

Measured memory_bytes: 43016
#include<bits/stdc++.h>
using namespace std;
#define ll long long
namespace io{
	const int l=1<<20;
	char buf[l],*s,*t;
	inline char gc(){
		if(s==t){
			t=(s=buf)+fread(buf,1,l,stdin);
			return s==t?EOF:*s++;
		}
		return *s++;
	}
	char c;
	template<class IT>inline void gi(IT &x){
		x=0;c=gc();while(c<'0'||c>'9')c=gc();
		while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^'0');c=gc();}
	}
};
using io::gi;
struct qwq{
	int a,b;
	inline bool operator<(const qwq &x)const{
		return a<x.a;
	}
};
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
const int N=205;
const double pi2=M_PI*2,pie=M_PI+0.00000001;
struct node{
	int x,y;double t;
	inline bool operator<(const node &a)const{
		return t<a.t;
	}
}x[N];
inline ll sqr(int a){return ((ll)a)*a;}
int main(){
	int n,i,r;ll mx=0ll;
	scanf("%d",&n);
	for(i=1;i<=n;++i){scanf("%d%d",&x[i].x,&x[i].y);x[i].t=atan2(x[i].y,x[i].x);}
	sort(x+1,x+n+1);
	for(i=1;i<=n;++i){x[i+n]=x[i];x[i+n].t+=pi2;}
	n<<=1;
	for(i=2;i<=n;++i){x[i].x+=x[i-1].x;x[i].y+=x[i-1].y;}
//	for(i=1;i<=n;++i)printf("%d %d %lf\n",x[i].x,x[i].y,x[i].t);
	n>>=1;
	for(i=1;i<=n;++i)for(r=i;r<i+n;++r)cmax(mx,sqr(x[r].x-x[i-1].x)+sqr(x[r].y-x[i-1].y));
	printf("%.30lf",sqrt(mx));
	return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    ll N;
    cin >> N;
    ll min = INF;
    ll t = 1;
    while (t * t <= N)
    {
        if (N % t == 0)
        {
            ll s = N / t;
            min = std::min(t - 1 + s - 1, min);
        }
        t++;
    }
    cout << min << endl;
    return 0;
}

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

int main(){

    int a,x,y;
    a=0;
	scanf("%d%d",&x,&y);
	while(x--){
	  long long int n,m,h;
	  double t;
	  scanf("%lld%lld",&n,&m);
	  h=n*n+m*m;
	  t=sqrt(h);
	  if(t<=y){
	  	a++;
	  }	
	}
	printf("%d",a);

	return 0;
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16

ll mod_pow(ll a,ll n,ll mod){
  ll res=1;
  while(n>0){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll N,M;
ll comb[2001][2001];
void make_table(){
  for(ll i=0;i<=2000;i++){
    comb[i][0]=1;
    comb[i][i]=1;
  }
  for(ll i=1;i<=2000;i++)for(ll j=1;j<i;j++){
    comb[i][j]=(comb[i-1][j-1]+comb[i-1][j])%M;
  }
}

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

  cin>>N>>M;
  make_table();

  ll res=0;
  repl(i,1,N){
    ll cnt=0; ll j=N-i;
    rep(k,i+1){
      ll v=mod_pow((mod_pow(2,i-k,M)-1+M)%M,j,M)*comb[i][k]%M;
      v%=M;
      if(k%2==0){
        cnt+=v; cnt%=M;
      }else{
        cnt+=M-v; cnt%=M;
      }
    }
    // dbg(i); dbg(j); dbg(cnt);
    cnt*=mod_pow(2,i*(i-1)/2,M); cnt%=M;
    cnt*=mod_pow(2,j*(j-1)/2,M); cnt%=M;
    res+=cnt*comb[N][i]%M; res%=M;
  }
  cout<<res<<endl;

  return 0;
}



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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.rbegin(), a.rend());
    //int total_vote = accumulate(a.begin(), a.end(), 0);
    int total_vote = 0;
    for(int i = 0; i < n; i++) total_vote += a[i];
    cout << ((a[m - 1] * 4 * m >= total_vote) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[55],b[55],c[55],d[55];
ll n,m,q,ans;
void f(vector<ll>v){
	if(v.size()==n+1){
		ll cnt=0;
		for(int i=0;i<q;i++){
			if(v[b[i]]-v[a[i]]==c[i])cnt+=d[i];
			ans=max(ans,cnt);
		}
		return;
	}
	v.push_back(v.back());
	while(v.back()<=m){
		f(v);
		v.back()++;
	}
}
int main(){
	cin>>n>>m>>q;
	for(int i=0;i<q;i++)cin>>a[i]>>b[i]>>c[i]>>d[i];
	vector<ll>x;
	x.push_back(1);
	f(x);
	cout<<ans<<endl;
	return 0;
}


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

int main() {
  int k, a, b;
  cin >> k >> a >> b;
  int ans;
  if(a % k == 0 || b % k == 0) {
    cout << "OK" << endl;
  }
  else {
    ans = ((a / k) + 1) * k;
    if(a <= ans && ans <= b) {
      cout << "OK" << endl;
    }
    else {
      cout << "NG" << endl;
    }
  }
}

Measured memory_bytes: 3580
#define _CRT_SECURE_NO_WARNINGS
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define range(i,a,b) for(int i = a; i < (int)(b); i++)
#define rep(i,b) range(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
using ll = long long;
// #define int ll
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
void fastios(){ ios_base::sync_with_stdio(0); cin.tie(0); }
int const mod = 1000000007;
auto const inf = numeric_limits<int>::max()/8;

using Weight = int;
using Capacity = int;
struct Edge {
    int src, dst; Weight weight;
    Edge(int s, int d, int w) : src(s), dst(d), weight(w) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

pair<vector<Weight>, bool> spfa(const Graph &g, int s){
    const Weight inf = numeric_limits<Weight>::max()/4;
    const int n = g.size(); queue<int> q;
    vector<Weight> dist(n, inf); vector<int> inQ(n);
    vector<int> count(n);
    dist[s] = 0; q.emplace(s); inQ[s] = true; ++count[s];
    bool negCycle = false;
    while(q.size()){
        int v = q.front(); q.pop(); inQ[v] = false;
        for(auto &e : g[v]){
            if(dist[v] != inf && dist[e.dst] > dist[v] + e.weight){
                dist[e.dst] = dist[v] + e.weight;
                if(!inQ[e.dst]){
                    q.emplace(e.dst); inQ[e.dst] = true; ++count[e.dst];
                    if(count[e.dst] >= n){ negCycle = true; goto END; }
                }
            }
        }
    }
 END:;
    return make_pair(dist, !negCycle);
}

int main(){
    fastios();
    int n;
    cin >> n;
    Graph g(n);
    rep(i,n){
        int u,k;
        cin >> u >> k;
        rep(j,k){
            int v,c;
            cin >> v >> c;
            g[u].eb(u,v,c);
        }
    }
    auto dist = spfa(g,0);
    rep(i,n){
        cout << i << ' ' << get<0>(dist)[i] << '\n';
    }
}

Measured memory_bytes: 9508
#include <cstdio>
#include <algorithm>

#define MOD (1000000000 + 7)

using namespace std;
int n, sol = 1;

int main()
{
    scanf("%d", &n);
    for(int i = 1; i<= n; ++i) sol = (1LL * sol * i) % MOD;
    printf("%d\n", sol);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#define int long long 
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
signed main() {
	int n, cnta = 0, cntb = 0, cntc = 0, cntd = 0, cnte = 0;
	string a, b, c;
	cin >> n >> a >> b >> c;
	rep(i, n) {
		if (a[i] == b[i] && b[i] == c[i])cnta++;
		else if (a[i] == b[i])cntb++;
		else if (b[i] == c[i])cntc++;
		else if (a[i] == c[i])cntd++;
		else cnte++;
	}
	cout << cnte * 2 + cntb + cntc + cntd << endl;
	getchar(); getchar(); return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

N, P = map(int, input().split())
S = list(map(int,list(input())))
U = [0 for i in range(N+1)]

d = 1
for i in range(N):
    U[N-(i+1)] = (U[N-i] + S[N-1-i] * d) % P
    d = 10 * d % P
    
def solve(U,S):
    if P == 2 or P == 5:
        return solve1(S)
    else:
        return solve2(U)
    
def solve1(S):
    ans = 0
    for i in range(N):
        if S[i] % P == 0:
            ans += i+1
    return ans

def solve2(U):
    ans = 0
    cnt = [0 for i in range(P)]
    for i in range(N+1):
        cnt[U[i]] += 1
    for i in range(P):
        p = cnt[i]
        ans += (p * (p-1)) // 2
    return ans

print(solve(U,S))

Measured memory_bytes: 12404
#include<iostream>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a<b&&b<c){
  cout<<"Yes"<<endl;
  }
  else{
  cout<<"No"<<endl;
  }
  return 0;
  }
  
  
  
  
  
  



Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <chrono>
#include <numeric>

using namespace std;

class cLSearch
{
	int mn, mq;
	string mS, mT;
	vector<int> vs, vt;
	int ans;

	void decode();
public:
	cLSearch(const int &n, const int &q, const string &s, const string &t)
	{
		mn = n;
		mq = q;
		mS = s;
		mT = t;

		decode();
	}

	void search();
	void output();
};

void cLSearch::search()
{
	sort(vs.begin(), vs.end());
	sort(vt.begin(), vt.end());
	int count = 0;
	vector<int>::iterator vis = vs.begin();
	vector<int>::iterator vit = vt.begin();

	int ts, tt;
	while (vis != vs.end() && vit != vt.end())
	{
		if (*vis == *vit)
		{
			++count;
			ts = *vis;
			tt = *vit;
			while (vis != vs.end() && ts == *vis)
				++vis;
			while (vit != vt.end() && tt == *vit)
				++vit;
		}
		else
		{
			if (vis != vs.end() && vit != vt.end() && *vis > *vit)
				++vit;
			else
				++vis;
		}
	}

	ans = count;
}

void cLSearch::output()
{
	cout << ans << endl;
}
void cLSearch::decode()
{
	istringstream iss;
	iss.str(mS);
	int ts;
	for (int i = 0; i < mn; ++i)
	{
		iss >> ts;
		vs.push_back(ts);
	}
	iss.str(mT);
	iss.seekg(0, iss.beg);
	for (int i = 0; i < mq; ++i)
	{
		iss >> ts;
		vt.push_back(ts);
	}
}

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

	int n, q;
	string s, t;
	cin >> n;
	cin.ignore();
	getline(cin, s);
	cin >> q;
	cin.ignore();
	getline(cin, t);

	cLSearch cls(n, q, s, t);
	cls.search();
	cls.output();

	return 0;
}

Measured memory_bytes: 3376
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int n = 0;
        for(int i = a; i <= b; i++){
            if(c % i == 0){
                n++;
            }
        }
        System.out.println(n);
    }
}


Measured memory_bytes: 26344
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef pair<int, int> P;

int n;
vector<P> ans;

signed main() {
	cin >> n;
	
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			string s;
			for (int k = 0; k < n; k++) {
				if (k == i || k == j) s += '1';
				else s += '0';
			}
			cout << "? " << s << endl; cout.flush();
			
			int d;
			cin >> d;
			if (d == 1) { ans.push_back(P(i, j)); }
			if (ans.size() == n - 1) { goto ANSWER; }
		}
	}
	
ANSWER:
	cout << "!";
	for (int i = 0; i < ans.size(); i++) {
		cout << " (" << ans[i].first << "," << ans[i].second << ")";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 1484
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define VPII vector<PII>
#define VPLL vector<PLL>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
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; }
#pragma endregion
//-------------------
ll diff(PLL a, PLL b, PLL c) {
    ll max=0, min=LINF;
    chmax(max, a.first*a.second);
    chmax(max, b.first*b.second);
    chmax(max, c.first*c.second);
    chmin(min, a.first*a.second);
    chmin(min, b.first*b.second);
    chmin(min, c.first*c.second);
    return max - min;
}

int solve(ll h, ll w) {
    ll ans = LINF;
    FOR(i,0,h) {
        int mid = (i+h)/2;
        chmin(ans, diff({i,w}, {mid-i,w}, {h-mid,w}));
        mid = w/2;
        chmin(ans, diff({i,w}, {h-i, mid}, {h-i, w-mid}));
    }
    return ans;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    ll h,w; cin >> h >> w;
    cout << min(solve(h,w), solve(w,h)) << endl;
    return 0;
}


Measured memory_bytes: 3604
use std::io::Read;


fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let s = iter.next().unwrap();
    let index = ["SUN","MON","TUE","WED","THU","FRI","SAT"].iter().position(|&v| v == s).unwrap();
    println!("{}", 7 - index);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
lld sum = 0;
int n;

void dfs(vector<ll> &x, vector<ll> &y, vector<bool> &visited, int curid, lld curdist)
{
    bool done = true;
    rep(i, n)
    {
        done &= visited[i];
    }
    if (done)
    {
        sum += curdist;
        return;
    }
    rep(i, n)
    {
        if (visited[i] == false)
        {
            visited[i] = true;
            lld newdist = curdist + sqrt((x[i] - x[curid]) * (x[i] - x[curid]) + (y[i] - y[curid]) * (y[i] - y[curid]));
            dfs(x, y, visited, i, newdist);
            visited[i] = false;
        }
    }
}
int main(int argc, char const *argv[])
{
    cin >> n;
    vector<ll> x(n), y(n);
    vector<bool> visited(n, false);
    rep(i, n) cin >> x[i] >> y[i];
    rep(i, n)
    {
        visited[i] = true;
        dfs(x, y, visited, i, 0.0);
        visited[i] = false;
    }
    int m = 1;
    rep(i, 1, n + 1)
    {
        m *= i;
    }
    printf("%0.10Lf\n", sum / (lld)m);
    return 0;
}


Measured memory_bytes: 256
H, W, K = map(int, input().split())
S = [input() for _ in range(H)]
ans = [[0] * W for _ in range(H)]

# Find strawberrys
B = []
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            B.append((i, j))

# Cut the cake
for i, b in enumerate(B):
    U, L, D, R = b[0], b[1], b[0], b[1]
    ans[b[0]][b[1]] = i + 1
    while True:
        if W > L - 1 >= 0 and S[U][L - 1] == '.' and ans[U][L - 1] == 0:
            ans[U][L - 1] = i + 1
            L -= 1
        else:
            break
    while True:
        if W > R + 1 >= 0 and S[D][R + 1] == '.' and ans[D][R + 1] == 0:
            ans[D][R + 1] = i + 1
            R += 1
        else:
            break
    while True:
        if H > U - 1 >= 0 and (not '#' in S[U - 1][L:R + 1]) and sum(ans[U - 1][L:R + 1]) == 0:
            for j in range(L, R + 1):
                ans[U - 1][j] = i + 1
            U -= 1
        else:
            break
    while True:
        if H > D + 1 >= 0 and (not '#' in S[D + 1][L:R + 1]) and sum(ans[D + 1][L:R + 1]) == 0:
            for j in range(L, R + 1):
                ans[D + 1][j] = i + 1
            D += 1
        else:
            break
for i in range(H):
    print(' '.join(map(str, ans[i])))


Measured memory_bytes: 61928
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef pair<int,int> P;
#define make_pair mp
#define first f
#define second s
int n,a,b,c,d;
int main(){
scanf("%d",&n);
scanf("%d %d %d %d",&a,&b,&c,&d);
int e=a%c==0?a/c:a/c+1;
int f=b%d==0?b/d:b/d+1;
printf("%d\r\n",n-max(e,f));
return 0;
}

Measured memory_bytes: 1024
n = int(input())
f = [[0 for j in range(10)] for i in range(n)]
p = [[0 for i in range(11)] for j in range(n)]
for i in range(n):
    f[i] = [int(i) for i in input().split()]
for i in range(n):
    p[i] = [int(i) for i in input().split()]

totalProfit = 0
N = [i for i in range(10)]  # N = bit探索する桁数
for i in range(1, 1 << len(N)):
    output = []
    for j in range(len(N)):
        if ((i >> j) & 1) == 1:
            output.append(j)  # このjが今回探索するindexの1つ
    profit = 0
    for j in range(n):
        sameOpen = 0
        for k in output:
            if f[j][k] == 1:  # 店j,曜日時間帯kと営業日被り
                sameOpen += 1
        profit += p[j][sameOpen]
        # print("store:{} sameOpen:{}".format(j, sameOpen))
    # print("profit:{} {}".format(profit, output))
    if i == 1:
        totalProfit = profit
    else:
        totalProfit = max(totalProfit, profit)
print(totalProfit)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    int a,b,c,k; cin>>a>>b>>c>>k;
    if(k<= a){
        cout << k << endl;
    }
    else if(a < k && k <= b){
        cout << a << endl;
    }
    else{
        cout << a - (k-a-b) << endl;
    }
}

Measured memory_bytes: 3652
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val S = ns()
    val ans = S.count(_ == 'o') * 100 + 700
    out.println(ans)
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int): Array[Int] = map(n)(_ => ni())
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }

  def sumL(as: Array[Int]): Long = {
    var s = 0L
    rep(as.length)(i => s += as(i))
    s
  }
}

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


int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  vector<ll> A(N), B(N), C(N), BC(N), ABC(N), s(N+1), t(N+1);
  for (ll i = 0; i < N; i++) cin >> A.at(i);
  for (ll i = 0; i < N; i++) cin >> B.at(i);
  for (ll i = 0; i < N; i++) cin >> C.at(i);
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());

  ll j = 0;
  for (ll i = 0; i < N; i++) {
    while (j < N && C.at(j) <= B.at(i)) j++;
    BC.at(i) = N - j;
  }

  s.at(N) = 0;
  for (ll i = N-1; i >= 0; i--) s.at(i) = s.at(i+1) + BC.at(i);

  t.at(N) = 0;
  for (ll i = N-1; i >= 0; i--) t.at(i) = t.at(i+1) + s.at(i);

  ll ans = 0;
  j = 0;
  for (ll i = 0; i < N; i++) {
    while (j < N && B.at(j) <= A.at(i)) j++;
    ans += s.at(j);
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 5760
//<--sbhmsh-->//

#include <bits/stdc++.h>
#include <iostream>
#define FASTIO std::ios::sync_with_stdio(false);
using namespace std;
#define lli long long int
#define endl '\n'
#define deb cout<<"sab_badhiya"<<endl;
// const long long INF = 1000 * 1000 * 1000 * 1ll * 1000 * 1000 * 1000;
const long INF = 1000 * 1000 * 1000;
const long long int mod = 1000000007;
int main(){
  FASTIO
  int n;
	cin>>n;
	double ans;
	if(n%2==0){
		ans=1/double(2);
	}
	else{
		ans=((n/2)+1)/double(n);
	}
	cout<<setprecision(8)<<fixed<<ans<<endl;
}


Measured memory_bytes: 256
from itertools import combinations
n = int(input())
dic = {i:0 for i in 'MARCH'}
for i in range(n):
    s = input()
    if s[0] in ('MARCH'):
        dic[s[0]] += 1
result = 0
for i, j, k in combinations('MARCH', 3):
    result += dic[i]*dic[j]*dic[k]
print(result)
    

Measured memory_bytes: 3060
#include<iostream>
#include<string>
using namespace std;
 
int main(){
	int n, l = 0, r = 0;
	string s[10000],t;
	cin >> n;
	for(int i=0;i<n;i++) cin >> s[i];
	cin >> t;
	for(int i=0;i<n;i++){
		string x,y;
		x = y = s[i];
		for(int j=0;j<x.length();j++) if(x[j]=='?') x[j] = 'a';
		for(int j=0;j<y.length();j++) if(y[j]=='?') y[j] = 'z';
		if(t<x) r++;
		else if(y<t) l++;
	}
	for(int i=l+1;i<=n-r+1;i++){
		if(i==n-r+1) cout << i << endl;
		else cout << i << ' ';
	}
}

Measured memory_bytes: 896
n = int(input())
h = [int(_) for _ in input().split(' ')]

if n >= 2:
    answer = 0
    while max(h) > 0:
        c = 1 if h[0] > 0 else 0
        for i in range(n - 1):
            if h[i] == 0 and h[i + 1] > 0:
                c += 1
        answer += c
        h = [max([i - 1, 0]) for i in h]
    print(answer)
else:
    print(h[0])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
  vector<char> s(4);
  rep(i, 4) cin >> s.at(i);
  sort(s.begin(), s.end());
  if(s.at(0)==s.at(1)&&s.at(1)!=s.at(2)&&s.at(2)==s.at(3)) cout << "Yes";
  else cout << "No";
}

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

int main()
{
    int n,k,q;
    cin >> n >> k >> q;
    if(k > q){
        for(int i=0; i<n; i++){
            cout << "Yes" << endl; 
        }
        return 0;
    }
    /*
    std::vector<int> a;
    int tmp = 0;
    for(int i=0; i<q; i++){
        cin >> tmp;
        a.push_back(tmp);
    }
    
    int check = q - k + 1;
    for(int i=0; i<n; i++){
        if(check <= std::count(a.begin(), a.end(), i+1)){
            cout << "Yes" << endl; 
        }else{
            cout << "No" << endl; 
        }
    }
    */
    int a[q];
    for(int i=0; i<q; i++){
        cin >> a[i];
    }
    int b[n];
    for(int i=0; i<n; i++){
        b[i] = 0;
    }
    
    for(int i=0; i<q; i++){
        b[a[i]-1]++;
    }
    int check = q - k + 1;
    for(int i=0; i<n; i++){
        if(check <= b[i]){
            cout << "Yes" << endl; 
        }else{
            cout << "No" << endl; 
        }
    }
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

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

    vector<int64_t> v(n);
    for (auto&& vv : v) {
        cin >> vv;
    }

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

    double ans = v[0];
    for (auto i : irange(1L, n)) {
        ans = (ans + v[i]) / 2.0;
    }

    cout << ans << endl;
}

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

int main()
{
long long int x[1000],n,i;

cin>>n;

for(i=1;i<=n;i++)
{

cin>>x[i];
}

for(i=n;i>=1;i--)
{

cout<<x[i];

if(i!=1)
    cout<<" ";
else
    cout<<endl;
}


}









Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int N;
string s1, s2;
int main(void) {
	cin >> N;
	cin >> s1 >> s2;

	ll ans;
	int prev; // 1:=縦 0:=横
	int start;
	if(s1[0] == s2[0]) {
		prev = 1;
		ans = 3;
		start = 1;
	}else {
		prev = 0;
		ans = 6;
		start = 2;
	}
	reps(i, start, N) {
		if(s1[i] == s2[i]) { // 縦
			if(prev == 0) { // 横
				ans *= 1;
			}else { // 縦
				ans *= 2;
			}
			prev = 1;
		}else { // 横
			if(prev == 0) { //横
				ans *= 3;
			}else { // 縦
				ans *= 2;
			}
			prev = 0;
			i++;
		}
		ans %= MOD;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#define ms(a) memset(a,0,sizeof(a))
typedef long long ll;
using namespace std;
const int maxn=200005;
const int INF=0x3f3f3f3f;
int n;
struct pss{
	int id;
	int val;
}a[100050],b[100050];
int f[100050];
bool cmp(struct pss a,struct pss b)
{
	return a.val<b.val;
}
bool check()
{
	for(int i=0;i<n;i++)
	{
		if(a[i].val>b[i].val) return false;
	}
	return true;
}
bool check1()
{
	for(int i=0;i<n-1;i++)
	{
		if(a[i+1].val<=b[i].val) return true;
	}
	return false;
}
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&a[i].val),a[i].id=i;
	for(int i=0;i<n;i++) scanf("%d",&b[i].val),b[i].id=i;
	sort(a,a+n,cmp);
	sort(b,b+n,cmp);
	if(!check()) cout<<"No"<<endl;
	else 
	{
		//for(int i=0;i<n;i++) cout<<a[i].val<<' ';
		//for(int i=0;i<n;i++) cout<<b[i].val<<' ';
		if(check1()) cout<<"Yes"<<endl;
		else
		{
			ms(f);
			for(int i=0;i<n;i++) f[a[i].id]=b[i].id;
			//for(int i=0;i<n;i++) cout<<f[i]<<endl;
			int cnt=f[0],num=1;
			while(cnt!=0)
			{
				cnt=f[cnt];
				num++;
			}
			if(num>n-1) cout<<"No"<<endl;
			else cout<<"Yes"<<endl;
		}
	}
}

Measured memory_bytes: 2176
import sys
def input():
  return sys.stdin.readline().rstrip()

N,K=map(int,input().split())
x=list(map(int,input().split()))

ans=1<<60
for i in range(N-K+1):
  left=x[i]
  right=x[i+K-1]
  a=min(abs(left),abs(right))+right-left
  ans=min(ans,a)

print(ans)


Measured memory_bytes: 84912
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main
{
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] tmp = br.readLine().split(" ");
        int N,Y;
        N = Integer.parseInt(tmp[0]); 
        Y = Integer.parseInt(tmp[1]);
        int x,y,z;
        x = -1; y = -1; z = -1;
        
        if(Y >= 100000){
            for(int i=0; i<=N; i++){
                for(int j=0; j<=N-i; j++){
                    if(Y == 10000*i + 5000*j + 1000*(N-i-j)){
                        x = i; y = j; z = N-i-j;
                    }
                }
            }
        } else {
            for(int i=0; i<=N; i++){
                for(int j=0; j<=N-i; j++){
                    if(Y == 1000*i + 5000*j + 10000*(N-i-j)){
                        x = N-i-j; y = j; z = i;
                    }
                }
            }
        }
        System.out.println(x + " " + y + " " +z);
    }
}

Measured memory_bytes: 23508