akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

void solve() {
	int h, w, m;
	cin >> h >> w >> m;
	
	vii t(m);
	vii rows(h), cols(w);
	for(int i = 0; i < h; i++) rows[i].ff = 0, rows[i].ss = i;
	for(int i = 0; i < w; i++) cols[i].ff = 0, cols[i].ss = i;
	
	for(int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		
		rows[x].ff++;
		cols[y].ff++;
		t[i] = {x, y};
	}
	
	sort(all(rows));
	sort(all(cols));
	int mxr = rows.back().ff, mxc = cols.back().ff;
	int cntr = 0, cntc = 0;
	vi r(h, 0), c(w, 0);
	for(int i = 0; i < h; i++) if(rows[i].ff == mxr) {
		cntr++;
		r[rows[i].ss] = 1;
	}
	
	for(int i = 0; i < w; i++) if(cols[i].ff == mxc) {
		cntc++;
		c[cols[i].ss] = 1;
	}
	
	int cnt = 0;
	for(int i = 0; i < m; i++) {
		if(r[t[i].ff] && c[t[i].ss]) cnt++;
	}
	
	ll cntt = cntr * 1ll * cntc;
	if(cnt == (cntt	)) {
		cout << mxr + mxc - 1 << endl;
	} else cout << mxr + mxc << endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}


Measured memory_bytes: 12740
fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val bricks = readLine()!!.split(" ").map { it.toInt() }
  var count = 0
  var result = 0
  for( i in 0 until bricks.count() ) {
    if (bricks[i] == count + 1) {
      count += 1
    } else {
      result += 1
    }
  }
  if (count == 0) {
    result = -1
  }
  print(result)
}

Measured memory_bytes: 82964
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;


constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
    template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
    template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
    template<typename T> void chadd(T& a, T b) { a = a + b; }

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t sz;
        inp(std::size_t _sz = 1) : sz(_sz) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { vector<T> a(sz); for (std::size_t i = 0; i < sz; i++) std::cin >> a[i]; return a; }
        template <typename T, typename U> operator std::pair<T, U>() const { T f; U s; std::cin >> f >> s; return std::pair<T, U>(f, s); }
    };

    inp inp1; // input one

    template<typename T>
    vector<T> bellman_ford(vector<vector<pair<int, T>>> g, int s, int trial = 1) {
        int n = (int)g.size();
        const auto inf = numeric_limits<T>::max();
        vector<T> dist(n, inf);
        dist[s] = 0;
        for (int i = 0; i < trial * (n - 1); ++i) {
            for (int u = 0; u < n; ++u) {
                for (const auto& e : g[u]) {
                    if (dist[u] == inf) continue;
                    dist[e.first] = min(dist[e.first], dist[u] + e.second);
                }
            }
        }

        return dist;
    }
}

int main() {

    int n, m;
    cin >> n >> m;

    vector<int> a(m), b(m), c(m);
    vector<vector<pair<int, ll>>> g(n);
    rep(i, m) {
        cin >> a[i] >> b[i] >> c[i];
        --a[i], --b[i];
        g[a[i]].push_back({ b[i], -c[i] });
    }

    vector<ll> dist1 = bellman_ford<ll>(g, 0, 1);
    vector<ll> dist2 = bellman_ford<ll>(g, 0, 2);

    if (dist1[n - 1] != dist2[n - 1]) Cout("inf");
    else Cout(-dist1[n - 1]);

    return 0;
}


Measured memory_bytes: 384
from collections import defaultdict
n=int(input())
d=list(map(int,input().split()))
mod=998244353
if d[0]!=0:
      print(0)
      exit()
dd=defaultdict(lambda:0)
for di in d:
      dd[di]+=1
if dd[0]>1:
      print(0)
      exit()
ans=1
for i in set(dd.keys()):
      if i==0:
            continue
      ans*=(dd[i-1]**dd[i])%mod
print(ans%mod)

Measured memory_bytes: 22364
import heapq
def main():
    x, y, a, b, c = map(int,input().split())
    p = list(map(int,input().split()))
    q = list(map(int,input().split()))
    r = list(map(int,input().split()))
    pp = select(p, x)
    qq = select(q, y)
    res = select(pp + qq + r, x + y)
    print(sum(res))



def select(array, length):
    ins = []
    res_l = []
    for part in array:
        heapq.heappush(ins,-part)
    for _ in range(length):
        res = heapq.heappop(ins)
        res_l.append(-res)
    return res_l


if __name__ == "__main__":
    main()


Measured memory_bytes: 39344
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

const int M=1000005;
ll F[M];

void Init(){
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

ll nCk(ll n,ll k){
	return Div(F[n],F[n-k]*F[k]%mod);
}

int n;
vi a;

int main(){
	Init();
	cin>>n;
	a=vi(n);
	for(int i=(n+1)/2;i<n;i++) a[i]=nCk(i-1,n-i-1)*F[i]%mod*F[n-i-1]%mod;
	ll res=0;
	for(int i=1;i<n;i++) (res+=(a[i]-a[i-1]+mod)*i)%=mod;
	cout<<res<<endl;
}

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

using namespace std;


#define ff				first
#define ss				second
#define int				long long
#define pb				push_back
#define mp				make_pair
#define pii				pair<int,int>
#define vi				vector<int>
#define mii 			map<int,int>
#define	pqb				priority_queue<int>
#define pqs				priority_queue<int,vi,greater<int> >
#define setbits(x)		__builtin_popcountll(x)
#define zrobits(x)		__builtin_ctzll(x)
#define mod				1000000007
#define inf 			1e18
#define ps(x,y)			fixed<<setprecision(y)<<x
#define mk(arr,n,type)	type *arr = new type[n]
#define w(x)			int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}


bool isPrime(int n)
{
	if (n <= 1)
		return false;
	if (n <= 3)
		return true;
	if (n % 2 == 0 || n % 3 == 0)
		return false;
	for (int i = 5; i * i <= n; i += 6)
	{
		if (n % i == 0 || n % (i + 2) == 0)
			return false;

	}
	return true;
}

vector<int> Sieve(int n)
{
	bool prime[n + 1];
	memset(prime, true, sizeof(prime));
	for (int i = 2; i * i <= n; i++)
	{
		if (prime[i])
		{
			for (int j = i * i; j <= n; j += i)
			{
				prime[j] = false;
			}
		}
	}
	vi primes;
	for (int i = 2; i <= n; i++)
	{
		if (prime[i])
			primes.pb(i);
	}
	return primes;
}



set<int> primeFactors(int  n)
{
	set<int> factors;
	while (n % 2 == 0)
	{
		n /= 2;
		factors.insert(2);

	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		while (n % i == 0)
		{
			factors.insert(i);
			n /= i;
		}
	}
	if (n > 2)
		factors.insert(n);
	return factors;
}


// int power(int x, unsigned int y, int p)
// {
// 	int res = 1;     // Initialize result

// 	x = x % p; // Update x if it is more than or
// 	// equal to p

// 	if (x == 0) return 0; // In case x is divisible by p;

// 	while (y > 0)
// 	{
// 		// If y is odd, multiply x with result
// 		if (y & 1)
// 			res = (res * x) % p;

// 		// y must be even now
// 		y = y >> 1; // y = y/2
// 		x = (x * x) % p;
// 	}
// 	return res;
// }
// Graph------------------------------------------------------------------------
// int n;/
int dp[100005];
int32_t main()
{
	FIO;
	//c_p_c();
//--------------------------------------------------


	int n;
	cin >> n;
	mk(arr, n, int);
	for (int i = 1; i <= n; i++)
		cin >> arr[i];


	dp[1] = 0;

	for (int i = 2; i <= n; i++)
	{
		dp[i] = dp[i - 1] + abs(arr[i] - arr[i - 1]);
		if (i > 2)
			dp[i] = min(dp[i], dp[i - 2] + abs(arr[i] - arr[i - 2]));
	}
	cout << dp[n];



}



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

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        return;

    }

    public static string Solve()
    {
        int[] input = ReadInts();
        int N = input[0];
        int K = input[1];
        if(N%2==0)
        {
            if (N / 2 >= K) return "YES";
        }
        else
        {
            if (N / 2 + 1 >= K) return "YES";
        }
        return "NO";
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

// Segment Tree {{{
template <typename T>
class SegTree {
 private:
    int _n;
    T _init_val;
    std::vector<T> _data;
    std::function<T(T, T)> _f;

    T _query(int a, int b, int k, int l, int r) {
        // [a b)と[l r]が交差しない
        if (r <= a || b <= l) return _init_val;

        // [a b)が[l r]を含む
        if (a <= l && r <= b) return _data[k];

        T vl = _query(a, b, k*2+1, l, (l+r)/2);
        T vr = _query(a, b, k*2+2, (l+r)/2, r);

        return _f(vl, vr);
    }

 public:
    SegTree(int n, T init_val, std::function<T(T, T)> f) {
        _init_val = init_val;
        _n = 1;
        _f = f;

        while (_n < n)
            _n *= 2;
        _data.resize(2 * _n, init_val);
    }

    T get(int k) {
        return _data[k + _n - 1];
    }

    void update(int k, T a) {
        k += _n-1;
        _data[k] = a;
        while (k > 0) {
            k = (k-1)/2;
            _data[k] = _f(_data[k*2+1], _data[k*2+2]);
        }
    }

    // [a b)の範囲でfを適用
    T query(int a, int b) {
        return _query(a, b, 0, 0, _n);
    }

    // 先頭からチェックし，はじめてxを満たしたインデックス
    int lower_bound(T x) {
        return _lower_bound(x, 0);
    }

    int _lower_bound(T x, int k) {
        if (k >= _n-1) {
            return k - (_n - 1);  // 葉
        } else if (_data[k] < x) {
            return _n;  // 該当なし
        } else if (x <= _data[k * 2 + 1]) {
            return _lower_bound(x, k * 2 + 1);
        } else {
            return _lower_bound(x - _data[k * 2 + 1] , k * 2 + 2);
        }
    }
};
// }}}

signed main() {
  // そのままの数列での累積和
  SegTree<ll> st1(200000,  0, [](const ll &x, const ll &y) { return x+y; });
  // 正数を取り出した数列における累積和
  SegTree<ll> st2(200000,  0, [](const ll &x, const ll &y) { return x+y; });

  ll N, K;
  cin >> N >> K;
  rep(i, N) {
    ll a;
    cin >> a;
    st1.update(i, a);
    st2.update(i, max(a, (ll)0));
  }

  ll ans = 0;
  for (ll i=0; i<=N-K; i++) {
    ll l = st2.query(0, i);
    ll m = st1.query(i,i+K);
    ll r = st2.query(i+K, N);

    // [i i+K) を黒くした場合
    ans = max(ans, l+m+r);

    // [i i+K) を白くした場合
    ans = max(ans, l+r);
  }
  cout << ans << endl;
}


Measured memory_bytes: 8448
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll N;
    cin >> N;
    vector<string> s(N);
    ll cnt = 0;
    ll bs = 0;
    ll ae = 0;
    ll bsae = 0;
    rep(i, N) {
        cin >> s[i];
        rep(j, s[i].size()-1) {
            if (s[i][j] == 'A' && s[i][j+1] == 'B') cnt++;
        }
        if (s[i][0] == 'B' && s[i].back() == 'A') {
            bsae++;
        } else if (s[i][0] == 'B') {
            bs++;
        } else if (s[i].back() == 'A') {
            ae++;
        }
    }
    if (bsae > 0) {
        if (bs > 0 && ae > 0) {
            bs--;
            ae--;
            print(cnt + (bsae-1) + 1 + 1 + min(bs, ae));
        } else if (bs == 0 && ae == 0){
            print(cnt + (bsae-1));
        } else {
            print(cnt+(bsae-1) + 1);
        }
    } else {
        print(cnt + min(bs, ae));
    }
    
    
    return 0;
}

Measured memory_bytes: 768
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

int gcd(int a, int b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

//-----------------------ここから-----------


int main(void){
    int n;
    cin >> n;
    string s = to_string(n);

    for(int i = 0; i < 3; i++){
        if(s[i] == '9'){
            s[i] = '1';
        } else if(s[i] == '1'){
            s[i] = '9';
        }
    }

    cout << s << endl;
}



Measured memory_bytes: 256
def x_i(r,D,x):
    return r*x-D

try:
    r,D,x_2000=map(int, input().split())
    assert 2<=r<=5 and 1<=D<=100 and D<x_2000<=200

    for i in range(2001,2011):
        print(r*x_2000-D)
        x_2000=r*x_2000-D
except AssertionError:
    print('')



Measured memory_bytes: 8996
//Bismillah Hir Rehmanir Rahim
//Allah knows best
using namespace std;
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#define mini -10000000000000000
#define start ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f(i, a, n) for( i=a; i<n;i++)
#define ll long long
#define pi 3.141592653589793
#define vi              vector<int>
#define si              set<int>
#define pb              push_back
#define mp              make_pair
#define mod             1000000007
#define rr              return 0
#define ff              first
#define in              insert
#define ss              second
#define setbits(x)      __builtin_popcountll(x)
#define zrbits(x)       __builtin_ctzll(x)
#define deb(x)          cout << #x << " = " << x << endl
ll power(ll a, ll b)
{ a = a%mod;
    ll ans = 1;
    while(b>0)
    {
        if(b&1) {
            ans = ans*a;
            ans = ans%mod;
        }
        a = a*a;
        a = a%mod;
        b>>=1;
    }
    return ans;
}
ll bhag(ll n, ll m){
  n%= mod; m%= mod;
  ll ans = n*power(m, mod-2);
  ans%= mod;
  return ans;
}
int main()
{
    start;
    //freopen("in.txt","r",stdin);
   ll i,j,k,n,m;
   cin>>n;
   ll a[n];
   f(i,0,n) cin>>a[i];
   k=0;
   for(i=0;i<n;i++)
    {
        k+=a[i];
        k%=mod;
    }
    k=k*k;
    k%=mod;
    m=0;
    for(i=0;i<n;i++)
    {
        m+=(a[i]*a[i]);
        m%=mod;
    }
    ll ans=(k-m+mod)%mod;
   // cout<<ans/2<<endl;
    cout<<bhag(ans,2)<<endl;
    rr;
}



Measured memory_bytes: 5180
#include <stdio.h>
int main(void) {
	int a,b,c,d;
	scanf("%d", &a);
	d = a % 10;
	a /= 10;
	c = a % 10;
	a /= 10;
	b = a % 10;
	a /= 10;
	if (a + b + c + d == 7) {
		printf("%d+%d+%d+%d=7\n", a, b, c, d);
	}else if (a + b + c - d == 7){
		printf("%d+%d+%d-%d=7\n", a, b, c, d);
	}else if (a + b - c + d == 7) {
		printf("%d+%d-%d+%d=7\n", a, b, c, d);
	}else if (a + b - c - d == 7) {
		printf("%d+%d-%d-%d=7\n", a, b, c, d);
	}else if (a - b + c + d == 7) {
		printf("%d-%d+%d+%d=7\n", a, b, c, d);
	}else if (a - b + c - d == 7) {
		printf("%d-%d+%d-%d=7\n", a, b, c, d);
	}else if (a - b - c + d == 7) {
		printf("%d-%d-%d+%d=7\n", a, b, c, d);
	}else printf("%d-%d-%d-%d=7\n", a, b, c, d);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int n,m,cnt;
char sa[1005][1005],s[1005];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i){
		scanf("%s",s+1);
		for(int j = 1; j <= m; j++){
			sa[i][j] = s[j];
		}	
	}
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			if(sa[i][j] == '#'){
				if(sa[i-1][j] == '#' && sa[i][j-1] == '#'){
					printf("Impossible");
					return 0;
				}else if(sa[i+1][j] == '#' && sa[i][j+1] == '#'){
					printf("Impossible");
					return 0;
				}
			}
	printf("Possible\n") ;
	return 0;
}

/*
###
..#
.#(#)
如果左边的#它不连通起点，则就得向左走才能把它走到
如果左边的#它连通起点，则上面的点如果不连通起点，也存在他同样的问题 
如果上面的点连通起点，则从起点到该点有两条路径，则如果要走完所有的点，一定得回头 
*/

Measured memory_bytes: 3784
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    double r;
    cin>>r;
    cout<<2*M_PI*r<<endl;
}

Measured memory_bytes: 3800
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace TestApp
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var str = int.Parse(Console.ReadLine());
                var str2 = int.Parse(Console.ReadLine());
                var i = Math.Pow(str, 2);
                var j = Math.Pow(Math.Pow(str2, 2) + Math.Pow(0.5*str, 2),0.5) * str * 0.5;
                if (str == 0 && str2 == 0)
                    break;
                Console.WriteLine(i + 4*j);
            }
        }
         
    }
 
}


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

def floor_sum(n, m, a, b):
    ans = 0
    if a >= m:
        ans += (n-1) * n * (a // m) // 2
        a %= m
    if b >= m:
        ans += b * (b // m)
        b %= m
    
    y_max = (a * n + b) // m
    x_max = y_max * m - b
    if y_max == 0:
        return ans
    ans += (n - (x_max + a - 1) // a) * y_max
    ans += floor_sum(y_max, a, m, (a - x_max % a) % a)
    return ans

def main():
    t = int(input())
    for i in range(t):
        n, m, a, b =map(int, input().split())
        res = floor_sum(n, m, a, b)
        print(res)

    
if __name__ == "__main__":
    main()



Measured memory_bytes: 78812
#include <iostream>
#include <utility>
#define N_MAX 10000
#define N_INF -1000000

//num[N]:整数Nを作るのに必要なマッチ棒の本数
int num[10]={0,2,5,5,4,5,6,3,7,6};
//dp[N]:N本使ってできる最大の桁数
int dp[N_MAX+1];

int main(){
  using namespace std;
  
  int i,k,flag,M,N,A[9];
  for(i=0;i<sizeof(dp)/sizeof(int);i++)dp[i]=N_INF;
  
  //入力
  cin >> N >> M;
  for(i=0;i<M;i++)cin>>A[i];
  	//A[]を降順にする
  do{
    flag=1;
    for(i=0;i<M-1;i++)
      if(A[i]<A[i+1]){swap(A[i],A[i+1]);flag=0;}
  }while(!flag);
  
  //dp[]の計算
  dp[0]=0;
  for(i=1;i<=N;i++){
    for(k=0;k<M;k++){
      if(i-num[A[k]]>=0){
        if(dp[i]<dp[i-num[A[k]]]+1)dp[i]=dp[i-num[A[k]]]+1;
      }
    }
  }
  
  //dp[]から逆算
  for(i=N;i>0;){
    for(k=0;k<M;k++){
      if(i-num[A[k]]<0)continue;
      if(dp[i]==dp[i-num[A[k]]]+1){
        cout<<A[k];i-=num[A[k]];break;
      }
    }
  }
  
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define INF 10000000
  
int matrixChainOrder(int *p, int n){
  int i, l, k, j, m[101][101], q;
  
  for(i = 1; i <= n; i++){
    m[i][i] = 0;
  }
  for(l = 2; l <= n; l++){
    for(i = 1; i <= n -l +1; i++){
      j = i +l -1;
      m[i][j] = INF;
      for(k = i; k < j; k++){
	q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
	if(m[i][j] > q){
	  m[i][j] = q;
	}
      }
    }
  }

  return m[i-1][j];
}
  
int main(){
  int i, n, p[100];

  scanf("%d", &n);

  for(i = 1; i <= n; i++){
    scanf("%d %d", &p[i-1], &p[i]);
  }
  printf("%d\n", matrixChainOrder(p,n));

  return 0;
}

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
    ll a, b, c, x, y; cin >> a >> b >> c >> x >> y;
    if(x<y){swap(x, y); swap(a,b);}
    if(x==y && a > b){swap(a,b);}
    ll ans = INF64;
    ans = min(ans, x*a+y*b);
    ans = min(ans, y*2*c+(x-y)*a);
    ans = min(ans, x*2*c);
    cout << ans << endl;
    return 0;
}

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

double EPS=1e-10;
double add(double a, double b){
    if(abs(a+b)<EPS*(abs(a)+abs(b))) return 0;
    else return a+b;
}
typedef complex<double> Pt;
double det(Pt a, Pt b){ //外積
    return add(a.real()*b.imag(),-a.imag()*b.real());
}

int main(){
	int n;  cin >> n;
    for(int i=0; i<n; i++){
        vector<Pt> p(4);
        for(int j=0; j<4; j++){
            double x, y;
            cin >> x >> y;
            p[j]={x,y};
        }

        p[1] -= p[0];
        p[3] -= p[2];
        
        cout << (det(p[1],p[3])==0 ? "YES" : "NO") << endl;
    }
}


Measured memory_bytes: 3140
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

// 二分累乗法
Int modpow(Int a, Int n, Int mod) {
    Int ret = 1;

    if (mod == 1) {
        while (n > 0) {
            if (n & 1) {
                ret = ret * a;
            }
            a = a * a;
            n >>= 1;
        }
    } else {
        while (n > 0) {
            if (n & 1) {
                ret = ret * a % mod;
            }
            a = a * a % mod;
            n >>= 1;
        }
    }

    return ret;
}

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

    Int x;
    cin >> x;

    Int ans = 0;
    for (int a = 1; a < 32; a++) {
        for (int n = 2; n < 11; n++) {
            Int tem = modpow(a, n, 1);
            if (tem <= x) {
                ans = max(tem, ans);
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

ll chek[100007];
ll num[100007];

int main(){
    ll N,M,l,r,C=0;
    cin >> N >> M;
    chek[1]=1;
    Rep(i,1,N+1){
        num[i]=1;
    }
    rep(i,M){
        cin >> l >> r;
        if(chek[l]==1){
            chek[r]=1;
        }
        num[l]--;
        if(num[l]==0){
            chek[l]=0;
        }
        num[r]++;
    }
    Rep(i,1,N+1){
        if(chek[i]==1 && num[i]>0){
            C++;
        }
    }
    cout << C << endl;
}

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

int main() {
  int n, m; cin >> n >> m;
  vector<long long> a(n);
  long long sum = 0;
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
    sum += a.at(i);
  }
  sort(a.rbegin(), a.rend());
  if(sum % (4*m) != 0){
    if(a.at(m-1) <= sum/(4*m)){
      cout << "No";
    }else{
      cout << "Yes";
    }
  }else{
    if(a.at(m-1) < sum/(4*m)){
      cout << "No";
    }else{
      cout << "Yes";
    }
  }
}


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

int a,b,k;

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

}


Measured memory_bytes: 3636
import copy

def main():
	n = int(input())
	a = []
	for _ in range(0, n):
		x = [int(x) for x in input().split()]
		a.append(x)
	
	cur = a[0]
	nxt = [0] * 3

	for i in range(1, len(a)):
		nxt[0] = max(a[i][0] + cur[1], a[i][0] + cur[2])
		nxt[1] = max(a[i][1] + cur[0], a[i][1] + cur[2])
		nxt[2] = max(a[i][2] + cur[1], a[i][2] + cur[0])

		cur = copy.deepcopy(nxt)

	print(max(cur[0], cur[1], cur[2]))

if __name__ == "__main__":
	main()

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

int main()
{
  int sum = 0;
  int a, b, m = 101;

  for (int i = 0; i < 4; i++){
    cin >> a;
    m = min(a, m);
    sum += a;
  }

  sum -= m;

  cin >> a >> b;

  sum += max(a, b);

  cout << sum << endl;
}

Measured memory_bytes: 3088
div = (10**9)+7
h,w = map(int, input().split())

dp = [[0]*(w+1) for _ in range(h+1)]

for i in range(h):
    a_h = input()
    for j in range(w):
        if((i==0) & (j==0)):
            dp[i+1][j+1] = 1
        else:
            if(a_h[j] == '.'):
                dp[i+1][j+1] = (dp[i+1][j] + dp[i][j+1])%div

print(dp[h][w])

Measured memory_bytes: 51052
#include <stdio.h>
#include <ctype.h>

int main(void)
{
    char c;
    int alfabet[26] = {0};
    int number;

    while (scanf("%c", &c)!=EOF)
    {
        if (c == ' '||c=='.'||c=='\n')
            continue;
        if (isupper(c))
            c = tolower(c);

        number = c - 'a';
        alfabet[number]++;
    }
    for (int i = 0; i < 26; i++)
    {
        printf("%c : %d\n", 'a' + i, alfabet[i]);
    }
    return 0;
}


Measured memory_bytes: 2048
cnt = int(input())
l = list(map(int, input().split()))
count = 0
 
for i in range(cnt-2):
  a,b, c = l[i], l[i+1], l[i+2]
  if (a < b and b < c) or( a>b and b> c):
    count += 1
print(count)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long x = Long.valueOf(scan.nextLine());
		long count = 0;
		count = x / 11 * 2;
		if(x % 11 >= 1 && x % 11 <= 6) {
			count++;
		} else if(x % 11 > 6) {
			count += 2;
		}
		System.out.println(count);
		scan.close();

	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <sstream>
#include <stdio.h>
#include<vector>
#include<climits>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<functional>
#include <numeric>
#include <map>
#define FORi(N) for(int i=0;i<N;++i)
#define FORj(N) for(int j=0;j<N;++j)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll gcd(ll m,ll n){
  if(n==0)return abs(m);
  return(gcd(n,m%n));
}
void putYN(bool b){
  if(b){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}
int main(){
  ll A,B,C;
  cin>>A>>B>>C;
  if((A<C&&C<B)||(B<C&&C<A)){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 888
def main():
    from math import pi

    R = int(input())

    print(2 * pi * R)


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()


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

int main(void) {
  vector<string> v(3);
  vector<char> member = {'a', 'b', 'c'};
  cin >> v[0] >> v[1] >> v[2];
  int who = 0;
  while (true) {
    if (v[who].size() == 0) {
      cout << char('A' + who) << endl;
      break;
    }
    char next = v[who][0];
    v[who].erase(v[who].begin());
    who = find(member.begin(), member.end(), next) - member.begin();
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<string>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<set>
#include<queue>
#include<cmath>

using namespace std;
#define LL long long

int N,M,ne[111111],ans=0;

int root(int x){
	if(ne[x]==x)return x;
	return ne[x]=root(ne[x]);
}
bool same(int x,int y){return root(x)==root(y);}
void unite(int x,int y){
	if(same(x,y))return;
	N--;
	x=root(x),y=root(y);
	ne[x]=y;
	return;
}

int main() {
	cin>>N>>M;
	for(int i=1;i<=N;i++)ne[i]=i;
	for(int i=0;i<M;i++){
		int x,y,z;
		cin>>x>>y>>z;
		unite(x,y);
	}
	cout<<N<<endl;
	return 0;
}



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

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

const ll inf = 1e15;
const ll mod = 1e9+7;

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

int main() {
    string s;
    cin >> s;
    
    ll i = 0;
    while (true) {
        ll j = i;
        if (s[i] == 'e') {
            // eraser + er
            if (s.substr(i, 8) == "eraserer") j += 6;
            // eraser + d
            else if (s.substr(i, 7) == "eraserd") j += 6;
            // eraser
            else if (s.substr(i, 6) == "eraser") j += 6;
            // erase
            else if (s.substr(i, 5) == "erase") j += 5;
        }
        if (s[i] == 'd') {
            // dreamer + er
            if (s.substr(i, 9) == "dreamerer") j += 7;
            // dreamer + d
            else if (s.substr(i, 8) == "dreamerd") j += 7;
            // dream + erase
            else if (s.substr(i, 10) == "dreamerase") j += 5;
            // dreamer
            else if (s.substr(i, 7) == "dreamer") j += 7;
            // dream
            else if (s.substr(i, 5) == "dream") j += 5;
        }
        
        if (j == i) {
            cout << "NO" << endl;
            return 0;
        }
        if (j == s.length()) break;
        i = j;
    }
    cout << "YES" << endl;
    
    return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

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

vector<ll> B;
vector<ll> PA;

ll func(ll k, ll X){
    if(k == 0) return 1;
    else{
        if(X == 1) return 0;
        else if((X >= 2) && (X <= B[k-1] + 1)){
            return func(k-1, X-1);
        }
        else if(X == B[k-1] + 2){
            return PA[k-1] + 1;
        }
        else if((X >= B[k-1] +3) && (X <= 2*B[k-1] + 2)){
            return func(k-1, X-B[k-1]-2) + PA[k-1] + 1;
        }
        else if(X == 2*B[k-1] + 3){
            return PA[k];
        }
    }
    return 0;
}

int main()
{
    cout << fixed << setprecision(15);

    ll N, X;
    cin >> N >> X;

    B.assign(N+1, 0);
    PA.assign(N+1, 0);

    B[0] = 1;
    PA[0] = 1;

    REP(i, N){
        B[i+1] = B[i]*2 + 3;
        PA[i+1] = PA[i]*2 + 1;
    }

    // func(N, X) Nレベルバーガーの
    cout << func(N, X) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acosl(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define MXN 200005

int main(){
    int n;
    scanf("%d",&n);
    int a[100005];
    for(int i = 0;i<n;i++)
        scanf("%d",&a[i]);
    sort(a,a+n);
    if(a[n-1]-a[0]>1){
        printf("No\n");
    }
    else{
        int cnt=0;
        int tot=0;
        for(int i = 0;i<n;i++){
            if(a[i]==a[n-1]-1)cnt++;
            else tot++;
        }
        a[n-1]-=cnt;
        if(cnt==0&&a[n-1]==n-1){
            printf("Yes\n");
        }
        else if(a[n-1]*2>tot||a[n-1]<=0){
            printf("No\n");
        }
        else{
            printf("Yes\n");
        }
    }
}
/*

23847657 
23458792534

102334155
111111111 
111111111
*/

Measured memory_bytes: 640
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x;
	cin >> x;
	int ans = 1;
	for(int b = 2; b <= x; ++b){
		for(int p = 2; pow(b,p) <= x; ++p){
			chmax(ans, (int)pow(b, p));
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4016
H,W=map(int, input().split())
w1=W//2
h1=H//2
if W%2!=0:
    w2=W//2+1
else:
    w2=w1
        
if H%2!=0:
    h2=H//2+1
else:
    h2=h1
print(w1*h1+w2*h2 if (H!=1)&(W!=1) else 1)

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
	char s[16];
	int a,b,i;
	for(i=0;i<9;i++){
		scanf("%s%d%d",s,&a,&b);
		printf("%s %d %d\n",s,a+b,a*200+b*300);
	}
	return 0;
}

Measured memory_bytes: 2564
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int a,b; 
    cin>>a>>b;
    if (b>a) swap(a,b);
    if (a-b>=2) cout << "Alice" << endl;
    else cout << "Brown" << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

vector<long long> divisor(long long n) {
    vector<long long> res;
    for (int i = 1; (long long)i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n / i) res.push_back(n / i);
        }
    }
    sort(begin(res), end(res));
    return res;
}

signed main() {
    ll n;
    cin >> n;
    int ans = 0;
    vector<ll> v1 = divisor(n), v2 = divisor(n - 1);
    for(auto k : v1){
        if (k == 1) continue;
        ll t = n;
        while (t >= k) {
            if (t % k == 0)
                t /= k;
            else
                t %= k;
        }
        if (t == 1) {
            ans++;
        }
    }
    for (auto k : v2) {
        if (k == 1) continue;
        ll t = n;
        while (t >= k) {
            if (t % k == 0)
                t /= k;
            else
                t %= k;
        }
        if (t == 1) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
from heapq import heapify, heappushpop
from itertools import accumulate

X, Y, Z, *ABC = map(int, open(0).read().split())

P = sorted(zip(*[iter(ABC)] * 3), key=lambda t: t[0] - t[1])

G = sum(t[0] for t in P[-X:])
S = sum(t[1] for t in P[:Y])
C = sum(t[2] for t in P[Y:-X])

Qg = [a - c for a, b, c in P[-X:]]
heapify(Qg)
B = [0] + [a - c - heappushpop(Qg, a - c) for a, b, c in reversed(P[Y:-X])]

Qs = [b - c for a, b, c in P[:Y]]
heapify(Qs)
F = [0] + [b - c - heappushpop(Qs, b - c) for a, b, c in P[Y:-X]]

print(G + S + C + max(a + b for a, b in zip(accumulate(F), reversed(list(accumulate(B))))))

Measured memory_bytes: 40268
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<ctime>
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
		return F?n:-n;
	}
	long long G()
	{
		long long n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
		return F?n:-n;
	}
}
const int M=998244353;
int fac[333333];
int ifac[333333];
int ex(int b,int e)
{
	int ans=1;
	for(;e;e>>=1,b=(long long)b*b%M)
		if(e&1)ans=(long long)ans*b%M;
	return ans;
}
int main()
{
	int n=io::F(),a=io::F(),b=io::F();
	long long k=io::G();
	fac[0]=1;
	for(register int i=1;i<=n;++i)fac[i]=(long long)fac[i-1]*i%M;
	ifac[n]=ex(fac[n],M-2);
	for(register int i=n-1;i>=0;--i)ifac[i]=ifac[i+1]*(long long)(i+1)%M;
	int ans=0;
	for(register int i=0;i<=n&&(long long)i*a<=k;++i)
		if((k-(long long)i*a)%b==0)
		{
			long long j=(k-(long long)i*a)/b;
			if(i<=n&&j<=n)ans=(ans+(long long)fac[n]*fac[n]%M*ifac[i]%M*ifac[j]%M*ifac[n-i]%M*ifac[n-j])%M;
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2560
S = input()
N = len(S) + 1
A, B = [0] * N, [0] * N

a, b = 0, 0
for i in range(N-1):
  a += 1 if S[i] == '<' else -a
  A[i+1] = a
  
  b += 1 if S[-i-1] == '>' else -b
  B[-i-2] = b
  
ans = 0
for i in range(N):
  ans += max(A[i], B[i])
  
print(ans)

Measured memory_bytes: 27316
#include <bits/stdc++.h>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> V;

int prime[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,
	     73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,
	     179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,
	     283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,
	     419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,
	     547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,
	     661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,
	     811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997};
int n;
int mod=1000000007;
int main(int argc, char *argv[])
{
  cin>>n;
  llong ans=1;
  REP(i,168){
    int j=1;
    llong a=0;
    while(pow(prime[i],j)<=n)
      a+=n/pow(prime[i],j++);
    ans = ((ans%mod) * ((a+1)%mod))%mod;
  }
  cout<<ans<<endl;
  return 0;
}

  

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

long long gcd(long long aaa,long long bbb) {
    if(bbb==0) {
        return aaa;
    }
    return gcd(bbb,aaa%bbb);
}

int main (){

    int X,ans=0,tmp;
    cin >> X;
    for(int i = 1; i <= X; i++) {
        for (int j = 2; j <= 1000; j++) {
            tmp = pow(i, j);
            if (tmp <= X) {
                ans = max(ans, tmp);
            } else {
                break;
            }
            if (ans == X) {
                cout << ans << endl;
                return 0;
            }
        }
    }
        cout << ans << endl;

        return 0;
    }


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

namespace program
{
    class Program
    {
        static void Main()
        {
          int N = Input.ScanInt()%500;
          int A = Input.ScanInt();
          
          Console.WriteLine(N<=A ? "Yes" : "No");
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 11092
H, W = map(int, input().split())
A = [input() for _ in range(H)]
dp = [[0] * W for _ in range(H)]
dp[0][0] = 1
MOD = 10**9 + 7
for y in range(0, H):
    for x in range(0, W):
        if A[y][x] == '#':
            continue

        if x - 1 >= 0:
            dp[y][x] += dp[y][x-1]
            dp[y][x] %= MOD
        if y - 1 >= 0:
            dp[y][x] += dp[y-1][x]
            dp[y][x] %= MOD
# print(*dp, sep='\n')
print(dp[-1][-1])


Measured memory_bytes: 53616
#include <stdio.h>

int main(void)
{
	int a,b,d,r;
	double f;
	scanf("%d %d",&a,&b);
	(((1<=a)&&(a<=1000000000))&&((1<=b)&&(b<=1000000000)));
	d=a/b;
	r=a%b;
	f=(double)a/(double)b;
	printf("%d %d %f\n",d,r,f);
	
	return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
typedef long long ll;
using namespace std;
 
int main(){
    int N,K; cin >> N >> K;
    int ans=0;
    rep(i,N){
        int h;
        cin >> h;
        if(h>=K) ans++;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main() {
    long long N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;

    for (int i = 0; i < N; i++) {
        long long ma = A + i * D - (N - 1 - i) * C;
        long long mi = A + i * C - (N - 1 - i) * D;
        if (B >= mi && B <= ma) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
M,D = map(int,input().split())
ans = 0
for m in range(1,M+1):
    for d in range(2,D+1):
        if d%10>=2:
            if int(d/10)>=2:
                if m == (d%10) * (int(d/10)):
                    ans += 1
print(ans)

Measured memory_bytes: 3060