akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
const int MOD = 1000000007;
using mint = Fp<MOD>;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vec A(n);
    rep(i,n) cin>>A[i];
    mint sum=0;
    rep(i,n) sum+=A[i];
    sum=sum*sum;
    rep(i,n) sum-=A[i]*A[i];
    sum/=2;
    cout<<sum;
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    long long K;
    cin >> N >> K;
    vector<long long> A(N);
    vector<long long> m, p;
    long long cz = 0;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        if(A[i] < 0) m.push_back(-A[i]);
        else if(A[i] == 0) cz++;
        else p.push_back(A[i]);
    }
    sort(m.begin(), m.end());
    sort(p.begin(), p.end());
    sort(A.begin(), A.end());
    long long ub = 2e18, lb = -2e18;
    while(ub - lb > 1){
        long long count = 0;
        long long cen = (ub + lb) / 2;
        long long temp = 0;
        for(int i = 0; i < N; i++){
            if(A[i] != 0) temp = (abs(cen) + abs(A[i]) - 1) / abs(A[i]);
            if(cen < 0){
                if(A[i] > 0) count += m.end() - lower_bound(m.begin(), m.end(), temp);
                else if(A[i] < 0) count += p.end() - lower_bound(p.begin(), p.end(), temp);
            }
            else if(cen == 0){
                if(A[i] > 0) count += cz + m.size();
                else if(A[i] == 0) count += (long long)(cz + m.size() + p.size());
                else count += cz + p.size();
            }
            else{
                if(A[i] > 0) count += cz + m.size() + upper_bound(p.begin(), p.end(), cen / A[i]) - p.begin();
                else if(A[i] < 0) count += cz + p.size() + upper_bound(m.begin(), m.end(), cen / abs(A[i])) - m.begin();
                else count += (long long)(cz + m.size() + p.size());
            }
            if(A[i]*A[i] <= cen) count--;
        }
        if(count >= 2*K) ub = cen;
        else lb = cen;
    }
    cout << ub << endl;
}



Measured memory_bytes: 3956
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cmath>
using namespace std;

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

const ll MAX_N = 1e5 + 5;
ll n, ans;
ll Arr[MAX_N];
ll Brr[MAX_N];
ll rev[MAX_N];
ll lp[MAX_N];
ll pr[MAX_N];
ll ind;
bool OK;

unordered_map <ll, ll> cnt, mark;

void preProcess() {
	for (ll i = 2; i < MAX_N; i++) {
		if (lp[i] == 0) {
			lp[i] = i;
			pr[ind++] = i;
		}

		for (ll j = 0; j < ind && pr[j] <= lp[i] && i * pr[j] < MAX_N; j++)
			lp[i * pr[j]] = pr[j];
	}
}
pii calc (ll d) {
	ll res1 = 1, res2 = 1, tmp = 0;
	for (int i = 0; i < ind && pr[i] * pr[i] <= d; i++) {
		if (d % pr[i] == 0) {
			tmp = 0;
			int cnt = 0;
			while (d % pr[i] == 0) {
				cnt++;
				d /= pr[i];
			}

			cnt %= 3;
			if (cnt == 1) {
				res1 *= pr[i];
				res2 *= pr[i] * pr[i];
			}
			if (cnt == 2) {
				res1 *= pr[i] * pr[i];
				res2 *= pr[i];
			}
		}
		tmp++;
		if (tmp == 2000)
			break;
	}

	if (d != 1) {
		res1 *= d;
		res2 *= d * d;
	}
	return {res1, res2};
}


int main() {
	preProcess();
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for (ll i = 0; i < n; i++) {
		cin >> Arr[i];

		if ((ll)cbrt(Arr[i]) * (ll)cbrt(Arr[i]) * (ll)cbrt(Arr[i]) == Arr[i]) {
			i--;
			n--;
			OK = true;
		}
	}

	for (ll i = 0; i < n; i++) {
		pii p = calc(Arr[i]);

		Brr[i] = p.first;
		rev[i] = p.second;

		cnt[Brr[i]]++;
	}

	ans = n;
	for (int i = 0; i < n; i++)
		if (!mark[Brr[i]]) {
			mark[Brr[i]] = 1;
			mark[rev[i]] = 2;

			ans -= min(cnt[Brr[i]], cnt[rev[i]]);
		}

	cout << ans + OK << "\n";
	return 0;
}

Measured memory_bytes: 20168
N,M,K=map(int,input().split())
*A,=map(int,input().split())
*B,=map(int,input().split())

AX=[0]*(N+1)
na=N+1
for i in range(1,N+1):
    AX[i]=AX[i-1]+A[i-1]
    if K<AX[i]:na=min(na,i)

BX=[0]*(M+1)
nb=M+1
for i in range(1,M+1):
    BX[i]=BX[i-1]+B[i-1]
    if K<BX[i]:nb=min(nb,i)

import bisect        
ans=0
for i in range(na):
 j=bisect.bisect_right(BX,K-AX[i])-1
 # print(na,t,i,j)
 ans=max(ans,i+j)
            
print(ans)

Measured memory_bytes: 47576
#include<bits/stdc++.h>
using namespace std;
int main()
{ int n,i;
cin>>n;
int a[n],f[n]={0};
for(i=0;i<n;i++) cin>>a[i];
if(n==1) cout<<0;
else if(n==2) cout<<abs(a[0]-a[1]);
else{
	f[0]=0;
	f[1]=abs(a[0]-a[1]);
	for(i=2;i<n;i++)
	{ f[i]=min((f[i-1]+abs(a[i]-a[i-1])),(f[i-2]+abs(a[i]-a[i-2])));
	}
//	for(auto g:f) cout<<g<<" ";
	
	
	cout<<f[n-1];
	
} 

	
	
	
	
}

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

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i, k , n) for(int i = k; i <= n; i++)
typedef long long ll;

const char nl = '\n' ;
const ll MOD = 1e9 + 7;


int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);
   int d, n; cin >> d >> n;
   if(!d)
   {
      if(n==100)
         cout << 101 << nl;
      else
         cout << n;

   }
   else if(d==1)
    {
       if(n ==100)
       {
          cout << n*100 +100;
       }
       else
         cout << n*100;
    }
    else
    {
       if(n==100)
         cout << n*100*100+100*100;
       else
         cout << n*100*100;
    }
   return 0;
}


Measured memory_bytes: 3652
n=int(input())
h=list(map(int,input().split()))

d=[0]*(n-1)
k=0
if n==1:
  print(0)
  exit()
for i in range(n-1):
  if h[i]-h[i+1]>=0:
    d[k]+=1
  else:
    k+=1
print(max(d))

Measured memory_bytes: 20460
from itertools import product

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

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

ite = product(range(2),repeat=10)
ans = -1*(10**9)
for it in ite:
    pattern = list(it)
    if 1 not in pattern: continue
    each_cnt = [0]*n
    for i,v in enumerate(pattern):
        if v == 1:
            for j,f in enumerate(fl):
                if f[i] == 1:
                    each_cnt[j] += 1
    val = 0
    for i, c in enumerate(each_cnt):
        val += pl[i][c]
    ans = max(ans,val)

print(ans)

Measured memory_bytes: 74220
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;
void YesNo(bool j){cout << (j ? "Yes" : "No") << endl; return;}
void yesno(bool j){cout << (j ? "yes" : "no") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}



int main() {
    char a;
    cin >> a;
    if(a>'Z') pt('a');
    else pt('A');

    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define inf 1001001001001000
#define mod 1000000007
#define pi 3.1415926535
using namespace std;
 
int main(void){
    ll n;
    cin>>n;
    vl a(n);
    ll ans = 0;
    rep(i,n){
        cin>>a[i];
        while(a[i]%2 == 0){
            ans++;
            a[i] /=2;
        }
    }cout<<ans<<endl;
    
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> arr{};
  for (int i = 0; i < n; ++i) {
    int p;
    cin >> p;
    arr.push_back(p);
  }
  sort(arr.begin(), arr.end());
  int sum = accumulate(arr.begin(), arr.begin()+k, 0);
  cout << sum << endl;
}


Measured memory_bytes: 3624
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        n: i64,
        a: i64,
    }
    let m = n % 500;
    if a < m {
        println!("No");
    } else {
        println!("Yes");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int solve(string &s, array<int, 4> &v){
    stack<int> S;
    for (auto &&i : s) {
        if(i == '[' || i == ']') continue;
        if(isalpha(i)){
            S.emplace(v[i-'a']);
        }else {
            int A = S.top(); S.pop();
            int B = S.top(); S.pop();
            if(i == '+') S.emplace(A|B);
            else if(i == '*') S.emplace(A&B);
            else if(i == '^') S.emplace(A^B);
        }
    }
    return S.top();
}

int main() {
    string s;
    while(cin >> s, s != "."){
        string t;
        cin >> t;
        array<int, 4> v{};
        for (int i = 0; i < 4; ++i) {
            v[i] = t[i]-'0';
        }
        reverse(s.begin(),s.end());
        int x = solve(s, v);
        int ans = 0;
        for (int i = 0; i < 10; ++i) {
            for (int j = 0; j < 10; ++j) {
                for (int k = 0; k < 10; ++k) {
                    for (int l = 0; l < 10; ++l) {
                        v = {i, j, k, l};
                        if(x == solve(s, v)) ans++;
                    }
                }
            }
        }
        cout << x << " " << ans << "\n";
    }

    return 0;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int n,m;
	cin>>n>>m;
	
	int ans=0;
	if(n>0) ans+=n*(n-1)/2;
	if(m>0) ans+=m*(m-1)/2;
	
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n), sum(n+1, 0);

  rep(i, n) {
    cin >> a[i];
  }

  sorti(a);

  for (int i = 0; i < n; ++i) {
    sum[i + 1] += sum[i] + a[i];
  }

  ll ans = 0;

  for (int i = 1; i < n; ++i) {
    ll now = sum[i];
    if (sum[i] * 2 >= a[i]) {
      ans += 1;
    } else {
      ans = 0;
    }
  }

  ans += 1;

  cout << ans << endl;
}


Measured memory_bytes: 1792
from collections import Counter
n = int(input())
v = list(map(int, input().split()))

a = Counter(v[::2]).most_common()
b = Counter(v[1::2]).most_common()
a.append([0,0])
b.append([0,0])
if a[0][0] != b[0][0]:
  print(n-(a[0][1] + b[0][1]))
else:
  print(min(n-(a[1][1] + b[0][1]), n-(a[0][1]+b[1][1])))

Measured memory_bytes: 20700
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(1, 1E8); \
                 auto rnd = bind(__dis, __gen)

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    vector<int> v;
    for (int len = 3, var = 27; len <= 9; ++len, var *= 3) {
        for (int i = 0; i < var; ++i) {
            int num = 0, base = 1, tmp = i, steps = len;
            int app[3] = {0, 0, 0}, val[3] = {3, 5, 7};
            while (steps--) num += base * val[tmp % 3], app[tmp % 3] = 1, tmp /= 3, base *= 10;
            if (app[0] and app[1] and app[2]) v.eb(num);
        }
    }
    
    int n;
    cin >> n;
    cout << upper_bound(ALL(v), n) - v.begin() << "\n";
    
    return 0;
}

Measured memory_bytes: 640
// 問題の URL を書いておく
// 

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#define TR() printf("%s(%d)\n", __FILE__, __LINE__)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)
#define TR() ((void)0)

#endif

#define rep(i, n) for(int i = 0; i < (int)(n); ++i)

using ll = int64_t;

const ll MIN = numeric_limits<ll>::min();

ll calc(int start, ll k, vector<int>& p, vector<ll>& c)
{
    int index = start;
    vector<int> indices(p.size());
    vector<ll> scores(p.size());
    ll currentScore = 0;
    ll icount = 0;
    indices.resize(0);
    scores.resize(0);
    // make graph 
    while(true)
    {
        indices.push_back(index);
        currentScore += c[index];
        scores.push_back(currentScore);
        icount++;
        if(p[index] == start)
        {
            break;
        }
        index = p[index];
    }

    ll maxScoreInLoop = MIN;
    for(ll i = 0; i < min(icount, k); ++i)
    {
        maxScoreInLoop = max(maxScoreInLoop, scores[i]);
    }

    auto loopScore = *scores.rbegin();
    if(loopScore < 0)
    {
        return maxScoreInLoop;
    }

    auto d = k / icount;
    auto m = k % icount;
    ll mScore = MIN;
    for(ll i = 0; i < m; ++i)
    {
        mScore = max(mScore, scores[i]);
    }
    auto c0 = d * loopScore + mScore;

    if(d > 0)
    {
        auto c1 = (d - 1) * loopScore + maxScoreInLoop;
        return max(c0, c1);
    }
    return c0;
}

int main(int, const char**)
{
    ll n, k;
    cin >> n >> k;
    vector<int> p(n);
    vector<ll> c(n);
    rep(i, n)
    {
        cin >> p[i];
        p[i]--;
    }
    rep(i, n)
    {
        cin >> c[i];
    }

    auto ans = MIN;
    rep(i, n)
    {
        ans = max(ans, calc(i, k, p, c));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3736
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

#define INF  -10000000000

int main()
{
    int n,q;
    string s;
    int l[100005];
    int r[100005];
    vector<int> ans;
    
    cin >> n >> q;
    cin >> s;
    for (int i = 0;i < q;i++){
        cin >> l[i] >> r[i];
    }
    
    for (int i = 0;i < n-1;i++){
        if (s[i] == 'A' && s[i+1] == 'C'){
            ans.push_back(i+1);
        }
    }
    for (int i = 0;i < q;i++){
        auto iter1 = lower_bound(ans.begin(),ans.end(),l[i]);
        auto iter2 = lower_bound(ans.begin(),ans.end(),r[i]-1);
        auto chec1 = upper_bound(ans.begin(),ans.end(),l[i]);
        auto chec2 = upper_bound(ans.begin(),ans.end(),r[i]-1);
    
        if (iter2 != chec2){
            cout << (iter2-ans.begin()) - (iter1-ans.begin()) +1 << endl;
        }
        else{
            cout << (iter2-ans.begin())-(iter1-ans.begin()) << endl;
        }
    }
}


Measured memory_bytes: 2044
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;

class FC{
public:
 int p[31];
 int n;

 bool is_over(){
	return    p[1]==p[2]&& p[2]==p[3]&& p[3]==p[4]&& p[4]==p[5]
		&& p[5]==p[6]&& p[6]==p[7]&& p[7]==p[8]&& p[8]==p[9]
		&& p[10]==p[11]&& p[11]==p[12]
		&& p[13]==p[14]&& p[14]==p[15]
		&& p[16]==p[17]&& p[17]==p[18]
		&& p[19]==p[20]&& p[20]==p[21]
		&& p[22]==p[23]&& p[23]==p[24]&& p[24]==p[25]&& p[25]==p[26]
		&& p[26]==p[27]&& p[27]==p[28]&& p[28]==p[29]&& p[29]==p[30] ;
 }
 void rot1(){
	swap(p[ 7],p[22]);swap(p[ 8],p[23]);swap(p[ 9],p[24]);
	swap(p[13],p[18]);swap(p[10],p[12]);
 }
  void rot2(){
	swap(p[ 1],p[28]);swap(p[ 2],p[29]);swap(p[ 3],p[30]);
	swap(p[15],p[16]);swap(p[19],p[21]);
 }
 void rot3(){
	swap(p[ 1],p[24]);swap(p[ 4],p[27]);swap(p[ 7],p[30]);
	swap(p[10],p[21]);swap(p[16],p[18]);
 }
 void rot4(){
	swap(p[ 3],p[22]);swap(p[ 6],p[25]);swap(p[ 9],p[28]);
	swap(p[12],p[19]);swap(p[13],p[15]);
 }
};

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

	for(int i=0;i<N;i++){
		FC now;
		for (int  j=1;j<=30;j++){
			cin>>now.p[j];
		}
		now.n=0;

		queue<FC>que;
		que.push(now);

		while(!que.empty()){
			now=que.front();
			que.pop();

			if(now.is_over()){
				cout <<now.n<<endl;
				break;
			}

			FC nex1=now;nex1.rot1();nex1.n++;que.push(nex1);
			FC nex2=now;nex2.rot2();nex2.n++;que.push(nex2);
			FC nex3=now;nex3.rot3();nex3.n++;que.push(nex3);
			FC nex4=now;nex4.rot4();nex4.n++;que.push(nex4);
		}
	}
return 0;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, m, y, k, z, N;
string s, t, d, c;


// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n >> m;
	vll a(n), b(m);
	for(ll i=0;i<n;i++) cin>>a[i];
	for(ll i=0;i<m;i++) cin>>b[i];
	if(a[0] <= 0) {
		z = -a[0];
		for(ll i=0;i<n;i++) a[i]+=z+1; 
	}
	if(b[0] <= 0) {
		z = -b[0];
		for(ll i=0;i<m;i++) b[i]+=z+1;
	}
	
	for(ll i=0;i<n;i++) {
		x += (i*a[i] - (n-i-1)*a[i]);
		x%=MOD;
	}
	for(ll i=0;i<m;i++) {
		y += (i*b[i] - (m-i-1)*b[i]);
		y%=MOD;
	}
	cout<<(x%MOD * y%MOD)%MOD;newl;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


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

using namespace std;
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;
#define mod 1000000007
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,l;
    cin>>n>>l;
    ll sum=0;
    ll mi=999999999;
    ll apple=-1;
    ll neg=0;
    for(ll i=1;i<=n;i++)
    {
        sum+=l+i-1;
        if(abs(l+i-1)<mi)
        {
            mi=abs(l+i-1);
            if(l+i-1<0)
                neg=1;
            else
                neg=0;
            apple=i;
        }
    }
    if(neg)
    {
        cout<<sum+mi<<endl;
    }
    else
        cout<<sum-mi<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
#include<cassert>
using namespace std;

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

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)

array<array<int,22>,22> kioku_field;
array<array<int,22>,22> real_field;

queue<pair<int,pii>> que;

int H,W;

int solve_maze(int i,int j){
	
//	for(auto& s: kioku_field){
//		fill(s.begin(),s.end(),0);
//	}
	kioku_field = real_field;
	//4houkou push
	int max_cost = 0;	
	que.emplace(0,pii{i,j});
	kioku_field[i][j] = 1;
	//cout<<"----"<<endl;
	while(!que.empty()){
		
		auto now_point = que.front();que.pop();
		//cout<<"np : "<<now_point.first<<endl;	
		
		int now_i = now_point.second.first ;
		int now_j = now_point.second.second;
		//cout<<"("<<now_i<<","<<now_j<<")"<<endl;
		

		if(max_cost <  now_point.first){
			max_cost = now_point.first;
		}

//		if(now_i - 1 >= 0 && field[now_i-1][now_j]!='#' && kioku_field[now_i-1][now_j] == 0)que.emplace(now_point.first+1,pii{now_i -1, now_j});
//		if(now_i + 1 < H && field[now_i+1][now_j]!='#'  && kioku_field[now_i+1][now_j] == 0)que.emplace(now_point.first+1,pii{now_i + 1, now_j});
//		if(now_j - 1 >= 0 && field[now_i][now_j-1]!='#'  && kioku_field[now_i][now_j-1] == 0)que.emplace(now_point.first+1,pii{now_i, now_j - 1});
//		if(now_j + 1 < W && field[now_i][now_j+1]!='#' && kioku_field[now_i][now_j+1] == 0)que.emplace(now_point.first+1,pii{now_i, now_j + 1});



		if(now_i - 1 >= 0 && kioku_field[now_i-1][now_j] == 0){
			kioku_field[now_i-1][now_j] = 1;
			que.emplace(now_point.first+1,pii{now_i -1, now_j});
		}
		
		if(now_i + 1 < H && kioku_field[now_i+1][now_j] == 0){
			kioku_field[now_i+1][now_j] = 1;
			que.emplace(now_point.first+1,pii{now_i + 1, now_j});
		}
	
		if(now_j - 1 >= 0 && kioku_field[now_i][now_j-1] == 0){
			kioku_field[now_i][now_j-1] = 1;
			que.emplace(now_point.first+1,pii{now_i, now_j - 1});
		}
	
		if(now_j + 1 < W && kioku_field[now_i][now_j+1] == 0){
			kioku_field[now_i][now_j+1] = 1;
			que.emplace(now_point.first+1,pii{now_i, now_j + 1});
		}


	}

	return max_cost;
}
int main(){

	
	cin>>H>>W;
	REP(i,H){
		REP(j,W){
			char c;
			cin>>c;

			if(c == '#'){
				real_field[i][j] = 1;
			}
			else{
				real_field[i][j] = 0;
			}
		}
	}
//	kioku_field = real_field;
//	REP(i,H){
//		REP(j,W){
//			cout<<real_field[i][j]<<endl;
//		}
//	}
//
//	kioku_field[0][0] = 7;
//	REP(i,H){
//		REP(j,W){
//			cout<<real_field[i][j]<<endl;
//		}
//	}
//
//
//
//	return 0;
	int max_cost = 0;
	REP(i,H){
		REP(j,W){

			if(real_field[i][j] == 1)continue;

			//cout<<i<<" "<<j<<" "<<k<<" "<<l<<endl;

			auto ans = solve_maze(i,j);
			max_cost = max(ans,max_cost);
		}
	}
	cout<<max_cost<<endl;
	return 0;
}



Measured memory_bytes: 256
A, B, C, D, E, F = map(int, input().split())
ans = [[0, 0]]
for i in range(0, F//100):
    if 100*A*i > F:
        break
    for j in range(0, F//100):
        if 100*A*i+100*B*j > F:
            break
        if 100*A*i + 100*B*j == 0:
            continue
        for k in range(0, F//C+1):
            for l in range(0, F//D+1):
                if 100*A*i + 100*B*j + C*k + D*l > F:
                    break
                if  (C*k + D*l)/(100*A*i + 100*B*j) > E/100:
                    break
                ans.append([(100*A*i + 100*B*j + C*k + D*l), (C*k + D*l)])
ans = sorted(ans, key=lambda x: x[1]/x[0] if x[0] != 0 else 0)
print(ans[-1][0], ans[-1][1])


Measured memory_bytes: 138748
void main(){
  import std.stdio, std.conv, std.string, std.algorithm;

  long n, a, b, k; rd(n, a, b, k);

  const long mod=998244353;
  const int M=1_000_00*4;
  auto fact=new long[](M);
  fact[0]=fact[1]=1;
  foreach(i; 2..M) fact[i]=i*fact[i-1]%mod;
  auto inv_fact=new long[](M);
  long powmod(long a, long x){
    if(x==0) return 1;
    else if(x==1) return a;
    else if(x&1) return a*powmod(a, x-1)%mod;
    else return powmod(a*a%mod, x/2);
  }
  foreach(i; 0..M) inv_fact[i]=powmod(fact[i], mod-2);
  long comb(long nn, long rr){
    long ret=fact[nn]%mod;
    (ret*=inv_fact[rr])%=mod;
    (ret*=inv_fact[nn-rr])%=mod;
    return ret;
  }

  long tot=0;
  for(long x=0; x<=n; x++)if(k-a*x>=0){
    if((k-a*x)%b==0){
      long y=(k-a*x)/b;
      if(y>n) continue;
      (tot+=comb(n, x)*comb(n, y)%mod)%=mod;
    }
  }
  writeln(tot);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}


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

using namespace std;

#define inf 1000000000

int main()
{
    int N, T;
    cin >> N >> T;
    int res=inf;
    int cnt=0;
    for(int i=1; i<=N; i++) {
        int a, b;
        cin >> a >> b;
        if(b>T) {
            cnt++;
        }
        if(b<=T) {
            res=min(res, a);
        }
    }
    if(cnt==N) {
        cout << "TLE" << endl;
    }
    else {
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
import collections
sys.setrecursionlimit(4100000)

n = int(input())
b = [int(i) for i in input().split()]
if n == 2:
    print(b[0]*2)
else:
    ans = 0
    for i in range(n-2):
        ans += min(b[i],b[i+1])
    print(ans+b[-1]+b[0])

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

int main(){
  int N;
  cin>>N;
  map<int64_t,int,greater<int64_t>> S;
  for(int i=0;i<N;++i){
    int64_t s;
    cin>>s;
    ++S[s];
  }

  int64_t ans=0;
  int count=0;
  vector<int64_t> pr(2);

  for(auto p:S){
    if(p.second>=4 && count==0){
      ans=p.first*p.first;
      break;
    }
    else if(p.second>=2){
      pr.at(count)=p.first;
      ++count;
    }
    if(count>=2){
      ans=pr.at(0)*pr.at(1);
      break;
    }
  }

  cout<<ans<<endl;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,n) for(int i=0;i<=(n);i++)
#define all(v) v.begin,v.end
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int MX = 1000005;

int main(){
    int n;
    ll ans=0;
    int a,b=0;
    cin>>n;
    rep(i,n){
        cin>>a;
        if(a<b){
            ans+=b-a;
        }
        else b=a;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3640
def string_to_float(s):
    return list(map(float, s.split()))

def solve():
    from sys import stdin
    lines = stdin.readlines()
    from itertools import combinations
    from math import acos, pi
    from cmath import phase
    from bisect import insort
    
    while True:
        n = int(lines[0])
        if n == 0:
            break
        
        circles = enumerate(map(string_to_float, lines[1:1+n]))
        cross_data = [[] for i in range(n)]
        included = [False] * n
        r_sum = sum(map(lambda x: float(x.split()[2]), lines[1:1+n]))
        ans = 2 * pi * r_sum
        
        for c1, c2 in combinations(circles, 2):
            n1, xyr1 = c1
            n2, xyr2 = c2
            if included[n1] or included[n2]:
                continue
            
            x1, y1, r1 = xyr1
            x2, y2, r2 = xyr2
            cn1 = x1 + y1 * 1j
            cn2 = x2 + y2 * 1j
            
            v12 = cn2 - cn1
            d = abs(v12)
            if d >= r1 + r2:
                continue
            elif  d <= abs(r1 - r2):
                if r1 < r2:
                    ans -= 2 * pi * r1
                    included[n1] = True
                else:
                    ans -= 2 * pi * r2
                    included[n2] = True
                continue
            
            a = acos((r1 ** 2 + d ** 2 - r2 ** 2) / (2 * r1 * d))
            t = phase(v12)
            s = t - a
            e = t + a
            cd = cross_data[n1]
            if s >= -pi and e <= pi:
                insort(cd, (s, -1))
                insort(cd, (e, 1))
            elif s < -pi:
                insort(cd, (s + 2 * pi, -1))
                insort(cd, (pi, 1))
                insort(cd, (-pi, -1))
                insort(cd, (e, 1))
            else:
                insort(cd, (s, -1))
                insort(cd, (pi, 1))
                insort(cd, (-pi, -1))
                insort(cd, (e - 2 * pi, 1))
            
            a = acos((r2 ** 2 + d ** 2 - r1 ** 2) / (2 * r2 * d))
            t = phase(-v12)
            s = t - a
            e = t + a
            cd = cross_data[n2]
            if s >= -pi and e <= pi:
                insort(cd, (s, -1))
                insort(cd, (e, 1))
            elif s < -pi:
                insort(cd, (s + 2 * pi, -1))
                insort(cd, (pi, 1))
                insort(cd, (-pi, -1))
                insort(cd, (e, 1))
            else:
                insort(cd, (s, -1))
                insort(cd, (pi, 1))
                insort(cd, (-pi, -1))
                insort(cd, (e - 2 * pi, 1))
        
        radius = map(lambda x: float(x.split()[2]), lines[1:1+n])
        flag = 0
        for cd, r in zip(cross_data, radius):
            for ang, f in cd:
                if flag == 0:
                    s = ang
                flag += f
                if flag == 0:
                    ans -= r * (ang - s)
                    
        print(ans)
        
        del lines[:1+n]

solve()


Measured memory_bytes: 6140
#include<iostream>
#define INFTY (1<<21)
using namespace std;

void maxsequence(int n) {
    int a[n], s[n], result = -INFTY;
    for ( int i = 0; i < n; i++ ) cin >> a[i];
    s[0] = a[0];
    for ( int i = 1; i < n; i++ ) s[i] = max(a[i], a[i] + s[i - 1]);
    for ( int i = 0; i < n; i++ ) result = max(result, s[i]);
    cout << result << endl;
}

int main() {
  int n;
  while ( cin >> n ) {
      if ( n == 0 ) return 0;
      maxsequence(n);
  }
}


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

int main(){
    int n;cin >> n;
    vector<int> a(n),b(n),c(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) cin >> c[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    vector<int> bc(n);
    vector<int> ab(n);
    int ind = 0;
    rep(i,n){
        while(b[i]>=c[ind] && ind < n) ind++;
        if(ind < n) bc[i] = n-ind;
        else bc[i] = 0;
    }
    //rep(i,n) cout << bc[i] << endl;
    if(bc[0]==0){
        cout << 0 << endl;
        return 0;
    }

    ind = 0;
    rep(i,n){
        while(a[i]>=b[ind] && ind < n) ind++;
        if(ind < n) ab[ind] = i+1;
    }
    rep(i,n-1) if(ab[i+1]==0) ab[i+1] = ab[i];
    ll ans = 0;
    rep(i,n) ans += ll(ab[i])*ll(bc[i]);

    cout << ans << endl;

}

Measured memory_bytes: 5372
#include<iostream>
#include<string>
#define WANTNUM 753
using namespace std;


int main(){
    string S,clip;
    int tmpNum = 0;
    int mindiff = WANTNUM,diff;
    cin >> S;
    for(int i = 0 ; i < S.length() - 2;i++){
        clip = S.substr(i,3);
        tmpNum = atoi(clip.c_str());
        diff = abs(WANTNUM - tmpNum) ; 
        if(mindiff > diff) mindiff = diff; 
    }

    cout << mindiff;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
string s;
int solve(string s){
	int k=0;
	for(int i=0;i<n;i++){
		int cnt=0;
		for(char j='a';j<='z';j++){
			bool x=false;
			bool y=false;
			for(int k=0;k<i;k++){
				if(s[k]==j){
					x=true;
				}
			}
			for(int k=i;k<n;k++){
				if(s[k]==j){
					y=true;
				}
			}
			if(x&&y){
				cnt++;
			}
		}
		k=max(k,cnt);
	}
	return k;
}
int main(){
	cin>>n>>s;
	int m;
	m=solve(s);
	cout<<m<<endl;
	return 0;
}

Measured memory_bytes: 256
N = gets.to_i
C = []
S = []
F = []
for i in 0..N-2
    C[i],S[i],F[i] = gets.split.map(&:to_i)
end

for i in 0..N-2

    a = 0

    for j in i..N-2
        
        a = F[j] * (0..10 ** 18).bsearch{|n| S[j]+F[j] * n >= a} + S[j] + C[j]

    end

    puts a

end

puts 0



Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define mod 1000000007
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
ll power(ll a,ll b) {
    if (b==0) return 1;
    ll c = power(a,b>>1);
    c = (c*c)%mod;
    if (b&1) return (c*a)%mod;
    return c;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)1e5+5;
const int Q = 301;

ll a[N], f[N];
ll comb(int n, int r) {
    return (f[n]*power((f[r]*f[n-r])%mod, mod-2))%mod;
}
void solve() {
    int n, k;
    cin>>n>>k;
    f[0] = 1;
    REP(i,1,n) {
        cin>>a[i];
        f[i] = (f[i-1]*i)%mod;
    }
    sort(a+1, a+n+1);
    ll ans = 0;
    REP(i,k,n) {
        ans = (ans + a[i]*comb(i-1, k-1))%mod;
    }
    REPN(i,n-k+1,1) {
        ans = (ans - a[i]*comb(n-i, k-1))%mod;
        if (ans < 0) ans += mod;
    }
    cout<<ans;
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 1792
#include<cstdio>
#include<algorithm>
using namespace std;
char s[5];
int main() {
	scanf("%s", s+1);
	sort(s+1, s+3+1);
	if( s[1] == 'a' && s[2] == 'b' && s[3] == 'c' )
		printf("Yes\n");
	else
		printf("No\n");
}

Measured memory_bytes: 128
def solve():
    N, M = [int(x) for x in input().split()]

    foods = set([i for i in range(1, M+1)])
    for i in range(N):
        a = list(map(int, input().split()))
        a = a[1:]
        notina = [x for x in range(1, M+1) if x not in a]
        for x in notina:
            if x in foods:
                foods.remove(x)
    # print(foods)
    print(len(foods))


def main():
    solve()


if __name__ == '__main__':
    main()

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long



int32_t main() {

    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) cin >> a[i];

    vector<int> gcdl(n), gcdr(n);

    gcdl[0] = a[0];
    for(int i = 1; i < n; ++i) {
        gcdl[i] = __gcd(gcdl[i-1], a[i]);
    }
    gcdr[n-1] = a[n-1];
    for(int i = n-2; i >= 0; --i) {
        gcdr[i] = __gcd(gcdr[i+1], a[i]);
    }

    int ans = 0;
    for(int i = 0; i < n; ++i) {
        int cand;
        if(i == 0) cand = gcdr[i+1];
        else if(i == n-1) cand = gcdl[i-1];
        else {
            cand = __gcd(gcdl[i-1], gcdr[i+1]);
        }
        ans = max(ans, cand);
    }

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


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
//int max(int a, int b) {if(b>a) return b; else return a;}
//int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;

signed main() {
    double n, m, d;
    cin >> n >> m >> d;
    cout << fixed << setprecision(10);

    if(d==0) {
        cout << (m-1)/n << endl;
    } else {
        cout << (m-1)*2.0*max(0.0, n-d)/(n*n) << endl;
    }

    return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    map<int, int> ma;
    for(int i = 1; i <= n; i++) {
        int val;
        cin >> val;
        ma[val]++;
    }

    if (ma.find(0) != ma.end() && ma[0] == n) cout << "Yes";
    else if (n % 3 != 0) cout << "No";
    else {
        int ans = 0;
        for(auto i : ma) {
            if (i.second % (n / 3)) {
                cout << "No";
                return 0;
            }
            for(int j = 0; j < i.second / (n / 3); j++)
                ans ^= i.first;
        }
        cout << (ans == 0 ? "Yes" : "No");
    }
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long
#define mp make_pair
const ll INF = 1e18;
const int MX=3 * 1e5 + 10;
int N, M;
ll dp[2002][3];
ll arr[MX];
ll Z, W;

int main()
{
    cin>>N>>Z>>W;
    for(int i=0; i<N; i++)
    {
        cin>>arr[i];
    }
    ll ans=abs(arr[N-1]-W);
    for(int i=N-2; i>=0; i--)
    {
        dp[i][0]=dp[i][1]=abs(arr[i]-arr[N-1]);
        for(int j=i+1; j<N-1; j++)
        {
            dp[i][0]=min(dp[i][0], dp[j][1]+abs(arr[i]-arr[j]));
            dp[i][1]=max(dp[i][1], dp[j][0]+abs(arr[i]-arr[j]));
        }
     ///   cout<<dp[i][1]<<" " <<dp[i][0]<<"\n";
    }
    ll best=1e18;
    for(int i=0;i<N-1;i++) best=min(best, dp[i][1]);
    if(best != 1e18) ans=max(ans, best);
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
r,g,b,n=map(int,input().split())
ans=0
for i in range(n//r+1):
    for j in range(n//g+1):
        if (n-(r*i+g*j))%b==0:
            if (n-(r*i+g*j))//b>=0:
                ans+=1
print(ans)

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



int main() {
    char x,y;
    cin >> x>>y;
    if(x>y) cout << '>' << endl;
    else if(x<y) cout << '<' <<endl;
    else cout << '=' <<endl;
}

Measured memory_bytes: 256
import sys

n,k = (int(i) for i in input().split())

d = [None]*k
a = [None]*k

syugou = []
for i in range(k):
    d[i] = int(input())
    a[i] = [int(j) for j in input().split()]

    syugou = syugou+a[i]

num = set(syugou)

print(n-len(num))

Measured memory_bytes: 9196
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using pint = pair<int, int>;

template <class T>
using vec = vector<T>;
template <class T>
using vec2 = vector<vec<T>>;
template <class T>
using vec3 = vector<vec2<T>>;

constexpr int INF = numeric_limits<int>::max();
constexpr ll INFL = numeric_limits<ll>::max();
constexpr ll MOD = 1000000007; // 10^9+7

#define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)

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

int H, W, M;
vec<pint> B;

int solve()
{
    map<int, int> y_map;
    rep(i, M)
    {
        y_map[B[i].first]++;
    }
    int y_max = -10;
    int y_max_cnt = 0;
    for (pint y : y_map)
    {
        if (chmax(y_max, y.second))
        {
            y_max_cnt = 0;
        }

        if (y.second == y_max)
        {
            y_max_cnt++;
        }
    }
    cerr << "y_max = " << y_max << " * " << y_max_cnt << endl;

    map<int, int> x_map;
    rep(i, M)
    {
        x_map[B[i].second]++;
    }
    int x_max = -10;
    int x_max_cnt = 0;
    for (pint x : x_map)
    {
        if (chmax(x_max, x.second))
        {
            x_max_cnt = 0;
        }

        if (x.second == x_max)
        {
            x_max_cnt++;
        }
    }
    cerr << "x_max = " << x_max << " * " << x_max_cnt << endl;

    cerr << "cross = " << y_max_cnt * x_max_cnt << endl;

    int cross_B = 0;
    rep(i, M)
    {
        if (y_map[B[i].first] == y_max && x_map[B[i].second] == x_max)
        {
            ++cross_B;
        }
    }
    cerr << "cross_B = " << cross_B << endl;

    if (cross_B == y_max_cnt * x_max_cnt)
        return y_max + x_max - 1;
    else
        return y_max + x_max;
}

int main()
{
    cin >> H >> W >> M;
    B.resize(M);
    rep(i, M)
    {
        cin >> B[i].first >> B[i].second;
    }
    cout << solve() << endl;
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int ans = 0;
    int N; cin >> N;
    int A[N+2]; rep(i, N) cin >> A[i+1];
    A[N+1] = -1;
    for(int i = 1; i <= N; i++){
        if(A[i] == i){
            swap(A[i], A[i+1]);
            ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long

using namespace std;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    if (a == 2 || b == 2) {
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 256
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    vector <double> v(n);
    for (int i = 0; i < n; i++) cin >> v[i];
    double ans = 0, maxans = -1;
    for (int i = 0; i< k; i++) ans += v[i];
  	maxans = max(ans, maxans);
    for (int i = 1; i <= n-k; i++){
        ans = ans-v[i-1]+v[i+k-1];
        maxans = max(maxans, ans);
    }
    ans = (maxans+k)/2;
    printf ("%.12f\n", ans);
    return 0;
}




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

points = {
    'taro': 0, 
    'hanako':0
}

loops = int(input())

for _ in range(loops):
    c_taro, c_hanako = map(str, input().split())
    if c_taro < c_hanako:
        points['hanako'] += 3
    elif c_taro > c_hanako:
        points['taro'] += 3
    else:
        points['hanako'] += 1
        points['taro'] += 1

print(points['taro'], points['hanako'])



Measured memory_bytes: 5604
//  main.cpp
//  CppTest

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {
    
    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    /////////////////////
    // Write code below /
    /////////////////////
    int N;
    cin >> N;
    vector<int>A(N);
    for (int i = 0; i < N; i++) cin >> A.at(i);
    
    double denominator = 0.0;
    for (int i = 0; i < A.size(); i++) {
        denominator += 1.0 / A.at(i);
    }
    double result = 1.0 / denominator;
    
    cout << result << endl;
    
    return 0;
}


Measured memory_bytes: 256