akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
    string s;
    cin>>s;
    int ans=s.size();
    for(int i=1;i<s.size();i++){
        if(s[i]!=s[i-1]){
           ans=min(ans,max(i,int(s.size()-i)));
        }
    }
    cout<<ans<<'\n';
}



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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif

int func(int a, int b, int c, int d){
    return abs(a-c) + abs(b-d);
}

signed main() {

    int W, H, N;
    cin>>W>>H>>N;
    int xmi=0, xma=W;
    int ymi=0, yma=H;
    
    rep(i,N){
        int x,y,a;
        cin>>x>>y>>a;
        if(a==2) xma=min(xma, x);
        if(a==1) xmi=max(xmi, x);
        if(a==4) yma=min(yma, y);
        if(a==3) ymi=max(ymi, y);
    }
    dump(xmi,xma,ymi,yma);
    if(xma-xmi<0 || yma-ymi<0) cout << 0 << endl;
    else cout << (xma-xmi)*(yma-ymi) << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
N,M,V,P=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
ans=0
pre_num=1
dsum=0
th=A[P-1]
for i in range(P,N):
    rest_m=M*(N-V)
    p=A[i]
    if th-p>M:break
    dsum+=(A[i-1]-p)*pre_num
    pre_num+=1
    rest_m-=dsum
    if rest_m<0:break
    ans+=1
print(P+ans)

Measured memory_bytes: 14964
#include <stdio.h>

int main(void)
{
	int A,B;
	int ans = -1;
	scanf("%d%d",&A,&B);
	ans=A+B;
	if(ans%2==0){
		ans=ans/2;
		printf("%d\n",ans);
	}
	else
	printf("IMPOSSIBLE\n");
	return 0;
}

Measured memory_bytes: 128
#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 INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

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

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

	switch (x % 7){
		case 0:
			cout << "thu" << endl;
			break;

		case 1:
			cout << "fri" << endl;
			break;

		case 2:
			cout << "sat" << endl;
			break;

		case 3:
			cout << "sun" << endl;
			break;

		case 4:
			cout << "mon" << endl;
			break;

		case 5:
			cout << "tue" << endl;
			break;

		case 6:
			cout << "wed" << endl;
			break;
	}
}



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

#define sz(a) (int)a.size()
#define re return
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(), a.end()
#define gr greater <int>

#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")

using namespace std;

typedef long long ll;
typedef string str;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;

///!!!<3<3<3<3<3!!!
void ProdamGaraje () {
   ll n, ans = 0;
   cin >> n;
   for (int i = 1; i <= n; ++i)
      if (i % 3 != 0 && i % 5 != 0)
         ans += i;
   cout << ans;
}
///!!!<3<3<3<3<3!!!
int main () {
   //freopen ("input.txt", "r", stdin);
   //freopen ("output.txt", "w", stdout);
   ios::sync_with_stdio(0);
   cin.tie(0); cout.tie(0);
   int tt = 1;
   //cin >> tt;
   while (tt--)
      ProdamGaraje ();
}
///GOOOOOOSE!!!!
/*
     ▄▀▀▀▄
▄███▀░0░░░▌
    ▌░░░░░▐
    ▌░░░░░▐
     ▌▌ ▌▌
     ▌▌ ▌▌
     ▌▌ ▌▌
     ▌▌ ▌▌
     ▌▌ ▌▌
   ▄▄▌▌▄▌▌        */


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#include <vector>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int num = a[0];
  int ans = 0;
  int before = 0;
  while(true){
    if(a[num - 1] == 0){
      ans = -2;
      break;
    }
    if(num == 2) break;
    ans++;
    int temp = num;
    num = a[temp - 1];
    a[before] = 0;
    before = temp - 1;
    if(num == 2) break;
  }
  cout << ans + 1 << endl;
  return 0;
}

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

int main() {
  int N,M;
  cin>>N>>M;
  if(N>M){
    for(int i;i<N;i++){
      cout << M;
    }
  }
  else {
    for(int i;i<M;i++){
      cout << N ;
    }
  }
  cout<<endl;
  
}

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

using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 50);

struct edge {
    int to, id;
    edge(int to, int id) : to(to), id(id) {}
};

vector<edge> to[50];

vector<int> es;
bool dfs(int v, int tv, int pv = -1) {
    // cout << "dfs: " << v << " " << tv << endl;
    if (v == tv) {
        return true;
    }
    for (auto e : to[v]) {
        if (e.to == pv) continue;
        if (dfs(e.to, tv, v)) {
            es.push_back(e.id);
            return true;
        }
    }
    return false;
}

void solve(long long N, std::vector<long long> a, std::vector<long long> b, long long M, std::vector<long long> u, std::vector<long long> v) {
    rep(i, N - 1) {
        int xu = a[i] - 1;
        int xv = b[i] - 1;
        to[xu].emplace_back(xv, i);
        to[xv].emplace_back(xu, i);
    }

    vector<ll> eset(M);
    rep(i, M) {
        int xu = u[i] - 1;
        int xv = v[i] - 1;
        es = vector<int>();
        dfs(xu, xv);
        for (auto e : es) {
            eset[i] |= (1LL << e);
        }
        // rep(i, es.size()) cout << es[i] << " ";
        // cout << endl;
        // debug(es.size());
        // debug(eset[i]);
    }

    ll ans = 0;
    rep(bits, 1 << M) {
        int mask = 0;
        rep(j, M) if (bits >> j & 1) mask |= eset[j];
        int white = __builtin_popcountll(mask);
        int now = 1LL << (N - 1 - white);
        // debug(now);
        if (__builtin_popcountll(bits) % 2)
            ans -= now;
        else
            ans += now;
    }
    cout << ans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    long long N;
    scanf("%lld", &N);
    std::vector<long long> a(N - 1);
    std::vector<long long> b(N - 1);
    for (int i = 0; i < N - 1; i++) {
        scanf("%lld", &a[i]);
        scanf("%lld", &b[i]);
    }
    long long M;
    scanf("%lld", &M);
    std::vector<long long> u(M);
    std::vector<long long> v(M);
    for (int i = 0; i < M; i++) {
        scanf("%lld", &u[i]);
        scanf("%lld", &v[i]);
    }
    solve(N, std::move(a), std::move(b), M, std::move(u), std::move(v));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pii std::pair<int,int>
#define mp std::make_pair
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};
int n,x[250005],y[250005],G[505][505],d[505][505];
int ans = 0;

/*

void bfs(int x,int y){
	std::deque<pii>q;
	q.push_back(mp(x,y));
	while (!q.empty()) {
		pii u = q.front(); q.pop_back();
		for (int dr=0;dr<4;++dr) {
			int x1 = u.first + dx[dr];
			int y1 = u.second + dy[dr];
			if (x1 < 1 || x1 > n || y1 < 1 || y1 > n) continue;
			if (d[x1][y1] > d[u.first][u.second] + G[x1][y1]) {
				d[x1][y1] = d[u.first][u.second] + G[x1][y1];
				if (G[x1][y1]) q.push_back(mp(x1,y1));
				else q.push_front(mp(x1,y1));
			}
		}
	}
}

*/

void dfs(int x,int y){
	for(int dr=0;dr<4;++dr){
		int x1 = x+dx[dr]; int y1 = y+dy[dr];
		if (x1<1||x1>n||y1<1||y1>n)continue;
		if (d[x1][y1] > d[x][y] + G[x1][y1]) {
			d[x1][y1] = d[x][y] + G[x1][y1];
			dfs(x1,y1);
		}
	}
}

int main(){
	scanf("%d",&n);
	for (int i=1;i<=n*n;++i) {
		int p;
		scanf("%d",&p);
		x[i] = (p-1)/n + 1;
		y[i] = (p-1)%n + 1;
	}
	for (int i=1;i<=n;++i)
	for (int j=1;j<=n;++j) {
		d[i][j] = std::min( { i, j, n-i+1, n-j+1 } ) ;
		G[i][j] = 1;
	}
	for (int i=1; i <= n*n; i++) {
		d[x[i]][y[i]] --; G[x[i]][y[i]] = 0;
		ans += d[x[i]][y[i]];
		dfs(x[i],y[i]);
	}printf("%d",ans);
	return 0;
}



Measured memory_bytes: 26864
#include <bits/stdc++.h>
#define ll long long
#define ii pair<ll, ll>
#define vi vector<ll>
#define vii vector<ii>
#define vs vector<string>
#define si set<ll>
#define endl "\n"
#define pb push_back
#define x first
#define y second
//g++ -std=c++11 -Wall -Wextra -pedantic-errors main.cpp -o main
const int ms = 1e3 + 5, base = 31, mod = 1e9 + 7;
using namespace std;

int N = 105, P = 1e5;
ll dp[105][100005];
vector<ll> weight, value;

si uses;
int bt(int i, ll j){//Get items
	if (i-1 < 0) return 0;
	if (dp[i][j] == dp[i-1][j]){
		return bt(i-1, j);
	}
	uses.insert(i);
	return bt(i-1, j-weight[i]) + 1;
}

int main(){
  cin >> N >> P;
 weight.push_back(0); value.push_back(0);
 memset(dp, 0, sizeof(dp));
 for (int i = 0; i <= N; i++){
  ll w, v; cin >> w >> v;
   weight.push_back(w);
   value.push_back(v);
 }
 for (int i = 0; i <= N; i++){//Iterative part
	for (int j = 0; j <= P; j++){
		ll a,b;
		(i > 0) ? a = dp[i-1][j] : a = 0;
		(i > 0 && j-weight[i] >= 0) ? b = dp[i-1][j-weight[i]] + value[i] : b = 0;
		dp[i][j] = max(a,b);
	}
}
  cout << dp[N][P] << endl;
  return 0;
  cout << "Max value: " << dp[N][P] << endl;
cout << "Number of itens in the bag: " << bt(N, P) << endl;
for (int i : uses) cout << "Weight: " << weight[i] << " Value: " << value[i] << endl;
 return 0; 
}

Measured memory_bytes: 82304
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define ABS(x) ( (x)>0 ? x : -(x) )
#define MIN(x,y) ( (x) < (y) ? (x) : (y) )
#define MAX(x,y) ( (x) > (y) ? (x) : (y) )

#define MOD 1000000007

void swap(int* a, int* b)
{
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

void print(int A[], int n)
{
	int i;
	for (i = 0; i < n; i++)
	{
		printf("%d", A[i]);
		if (i != n - 1)
			printf(" ");
	}
	printf("\n");
}

void insertionSort(int A[], int N)
{
	int i, j,tmp;

	for (i = 1; i < N; i++)
	{
		j = i;
		while (j > 0 && A[j - 1] > A[j])
		{
			tmp = A[j - 1];
			A[j - 1] = A[j];
			A[j] = tmp;

			j--;
		}
		print(A, N);
	}
}

void bubbleSort(int A[], int N,int *count)
{
	int flag = 0;
	int i, j,tmp;

	for (i = 0; i < N; i++)
	{
		for (j = N - 1; j > 0; j--)
		{
			if (A[j - 1] > A[j])
			{
				tmp = A[j - 1];
				A[j - 1] = A[j];
				A[j] = tmp;
				flag = 1;
				(*count)++;
			}
		}
		if (flag == 0)
			break;
		else
			flag = 0;
	}
}

int main()
{
	int A[10000];
	int N, i;

	int count = 0;

	scanf("%d", &N);

	for (i = 0; i < N; i++)
		scanf("%d", &A[i]);

	//print(A, N);

	bubbleSort(A, N,&count);

	print(A, N);

	printf("%d\n", count);

	return 0;
}


Measured memory_bytes: 2088
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
typedef pair<int, int> PII;
typedef long long ll;
template<typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;


string s;

int main() {

	cin >> s;

	if (s == "SUN")cout << 7 << endl;
	if (s == "MON")cout << 6 << endl;
	if (s == "TUE")cout << 5 << endl;
	if (s == "WED")cout << 4 << endl;
	if (s == "THU")cout << 3 << endl;
	if (s == "FRI")cout << 2 << endl;
	if (s == "SAT")cout << 1 << endl;

	return 0;
}

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

int main(void) {

	int N;
	cin >> N;

	struct stu {
		int No;
		int kazu;
		bool operator<(const stu& another) const
		{
			return kazu < another.kazu;//年齢を比較
		};
	};

	vector<stu> seito(N);


	for (int i = 0; i < N; i++) {
		cin >> seito[i].kazu;
		seito[i].No = i;
	}

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

	for (int i = 0; i<N; i++) {
		cout << seito[i].No+1<<" ";
	}

}



Measured memory_bytes: 1536
N=int(input())
*L,=map(int, input().split())
L.sort()

ans=0
from bisect import bisect_right
for i in range(N-1,-1,-1):
    li = L[i]
    for j in range(i-1,-1,-1):
        lj = L[j]
        k = bisect_right(L, li-lj)
        ans += max(0, j-k)
print(ans)

Measured memory_bytes: 3188
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int n, a[111], b;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    int mi = a[0];
    for(int i = 0; i < n; i++)
    {
        for(int j = i; j < n; j++)
        {
            if(a[i] >= a[j])
                {
                    b = a[i];
                    a[i] = a[j];
                    a[j] = b;
                }
        }
    }

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

    cout << s << " ";

    return 0;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll MAXN = 100000;

int n;
ll A[MAXN + 1];

bool solve(ll id){
    assert(id >= 1 && id <= n);
    ll now = A[id];
    for(int i=1;i<=n;i++){
        if(i == id) continue;
        if(A[i] <= now * 2){
            now += A[i];
        }else{
            return false;
        }
    }
    return true;
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cin >> n;
    A[0] = 0;
    for(int i=1;i<=n;i++) cin >> A[i];
    sort(A, A + (n + 1));
    // for(int i=0;i<=n;i++) cout << A[i] << endl;
    // index of sorted A
    ll left = 0, right = n;
    while(right - left > 1){
        ll mid = (left + right)/2;
        if(solve(mid)){
            // midが条件を満たせば、解の存在範囲は(left, mid]
            right = mid;
        }else{
            // 解の存在範囲は(mid, right]
            left = mid;
        }
    }
    cout << n - right + 1 << endl;
}

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


int main()
{
	int n; cin >> n;
	for (int i = 1; i < 10; ++i)
		if (n%i == 0 && n/i < 10)
		{
			cout << "Yes" << endl;
			return 0;
		}
	cout << "No" << endl;
}



Measured memory_bytes: 3608
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin >> N;
	int size = 2*N-1;
	vector<int> A(size);
	for(int i=0;i<size;++i){
		cin >> A[i];//[1,2N-1]
	}
	/////
	int OK = 1;
	int NG = 2*N;
	int mid;
	vector<int> v(size);
	const int cen = N-1;
	while(NG-OK>1){
		mid = (OK+NG)/2;
		for(int i=0;i<size;++i){
			v[i] = (A[i] >= mid);
		}

		if( v[cen] == v[cen-1] || v[cen] == v[cen+1] ){
			if( v[cen] ){
				OK = mid;
			}else{
				NG = mid;
			}
			continue;
		}

		int L = N;
		int R = N;
		int now = v[cen];
		for(int i=cen-1;i>=0;--i){
			if( now != v[i] ){
				L = i;
				now = v[i];
			}else{
				++L;
				break;
			}
		}
		now = v[cen];
		for(int i=cen+1;i<2*N-1;++i){
			if( now != v[i] ){
				R = i;
				now = v[i];
			}else{
				--R;
				break;
			}
		}
		//[L,R]まで交互に

		int LLval = -1;
		int RRval = -1;
		if( L != 0 ){
			LLval = v[L-1];
		}
		if( R != 2*N-2 ){
			RRval = v[R+1];
		}

		if( R-L+1 == 2*N-1 ){//全てが交互
			int res;
			if(N&1){
				res = v[cen];
			}else{
				res = (v[cen]+1)%2;
			}
			if( res ){
				OK = mid;
			}else{
				NG = mid;
			}
			continue;
		}
		int Len = (R-L+1);
		if(Len&1){//長さが奇数=両外が同じ
			int res;
			if(LLval != -1 ){
				res = LLval;
			}
			if(RRval != -1 ){
				res = RRval;
			}
			if( res ){
				OK = mid;
			}else{
				NG = mid;
			}
			continue;
		}else{//長さが偶数
			int res;
			if( (cen-L) > (R-cen) ){
				//右の値が出てくる
				res = RRval;
			}else{
				//左の値が出てくる
				res = LLval;
			}
			if( res ){
				OK = mid;
			}else{
				NG = mid;
			}
			continue;
		}
	}
	cout << OK << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define pob pop_back();
#define for_t int t;cin>>t;while(t--)
#define MOD 1000000007
#define fi first
#define se second
#define le length
#define debug(n1) cout << n1 << endl
#define set_bits(n) __builtin_popcount(n);
#define rep(i , j , n) for(ll i = j ; i <= n ; i++)
#define per(i , j , n) for(ll i = j ; i >= n ; i--)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;

int root(int i, vi &parent){
    while(i!=parent[i]){
        i=parent[i];
    }
    return i;
}

void union1(int i, int j, vi &size, vi &parent){
    int x = root(i, parent);
    int y = root(j, parent);
    if(size[x]<size[y]){
        parent[x]=y;
        size[y]=size[y]+size[x];
    }
    else{
        parent[y]=x;
        size[x]=size[x]+size[y];
    }
}

int main() {
    SPEED;
    int n;
    cin>>n;
    n--;
    vi vec(n);
    rep(i,0,n-1){
        cin>>vec[i];
    }
    int ans =0;
    ans = ans+vec[0]+vec[n-1];
    rep(i,1,n-1){
        ans=ans+min(vec[i], vec[i-1]);
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <stdio.h>

typedef long long lli;

int main() {
	lli n, k;
	scanf("%lld %lld",&n,&k);
	if(k==0) {
		printf("%lld\n",n*n);
		return 0;
	}
	lli res=0;
	for(lli a=k+1;a<=n;a++) {
		for(lli b=a;b<=n;b+=a) {
			res+=a-k;
		}
		lli rem=n%a;
		if(rem==0) continue;
		if(rem>k-1) res+=rem-k+1;
	}
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 128
def main():
    n = int(input())
    ans = 0
    e = 1
    facs = (2 if x == 0 else x * 2 + 1 for x in range(10 ** 6))
    for fac in facs:
        while n % (div := pow(fac, e)) == 0:
            n //= div
            ans += 1
            e += 1
        while n % fac == 0:
            n //= fac
        if fac * fac > n:
            break
        e = 1

    if n != 1:
        ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9176
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>
#include <stdio.h>

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
const ll INF = 1e15;
const ld eps = 1e-6;
const ll MOD = 1e9 + 7;

const double pi = acos(-1.0);

int main() {
	ll N, M, C;
	cin >> N >> M >> C;
	vector<ll> B(M);
	for (int i = 0;i < M;i++)
		cin >> B[i];
	ll ans = 0;
	for (int i = 0;i < N;i++) {
		ll c = C;
		for (int j = 0;j < M;j++) {
			ll a;
			cin >> a;
			c += a*B[j];
		}
		if (c > 0)
			ans++;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main()
{
    int K, N;
    cin >> N >> K;
    vector<int> p(N);
    for(int i = 0; i < N; i++){
        cin >> p[i];
    }
    
    int sum = 0;
    sort(p.begin(), p.end());
    for(int i = 0; i < K; i++) {
        sum += p[i];
    }
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 3624
using System;

class AbC
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        long[] NA = new long[N + 2];
        NA[0] = 2;
        NA[1] = 1;
        for (int i = 0 ;i < N ;i++ )
        {
            NA[i + 2] = NA[i] + NA[i + 1];
        }
        Console.WriteLine(NA[N]);
    }
}


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

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define repf(i, f, l) for(int i = f; i < (int)l; ++i)
#define repit(it, t) for(__typeof((t).begin()) it = (t).begin(); it != (t).end(); it++)
#define endl "\n"
#define pb emplace_back
#define lb lower_bound
#define int long long
#define ul unsigned long
#define ull unsigned long long
#define ll long long
#define INF 1000000007
#define MOD 1000000007
#define fs first
#define sd second
#define DBG0(x) { cout << #x << ": " << x << "\t"; }
#define DBG(x) {DBG0(x); cout << endl;}
#define DBG2(x, y) {DBG0(x); DBG(y);}
#define DBG3(x, y, z) {DBG0(x); DBG2(y, z);}
#define DBG4(w, x, y, z) {DBG0(w); DBG3(x, y, z);}

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ul> vul;
typedef vector<ull> vull;
typedef vector<bool> vbl;
typedef pair<int, int> pii;

signed main(void){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vint ls = vint(n);
    rep(i, n) cin >> ls[i];
    sort(ls.begin(), ls.end());
    reverse(ls.begin(), ls.end());

    int sum = 0;
    repf(i, 1, n) sum += ls[i];
    cout << ((ls[0] < sum) ? "Yes" : "No") << endl;



    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int H[25];
  for(int i=0;i<N;i++){    cin>>H[i];  }
  int ans=1;
  for(int i=1;i<N;i++){
    bool yuri=true;
    for(int j=0;j<i;j++){
      if(H[j]>H[i]){
        yuri=false;
      }
    }
    if(yuri){
      ans++;
    }
  }
  cout<<ans<<endl;
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

template<class T> inline bool cmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool cmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MOD=1000000007;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll MAXN=3e3+5;
const ll MAXLG=__lg(MAXN)+2;


ll n,a[MAXN];
ll dp[MAXN][MAXN];
/********** Good Luck :) **********/
int main()
{
    IOS();
    cin >> n;
    REP (i,n) {
        cin >> a[i];
    }

    for (ll len=0;len<n;len++) {
        for (ll l=0;l+len<n;l++) {
            if (!len) {
                dp[l][l+len] = (n-len&1) ? a[l] : -a[l];
            } else {
                if (n-len & 1) {
                    dp[l][l+len] = max(dp[l+1][l+len]+a[l],dp[l][len+l-1]+a[l+len]);
                } else {
                    dp[l][l+len] = min(dp[l+1][len+l]-a[l],dp[l][len-1+l]-a[l+len]) ;
                }
            }
        }
    }
    cout << dp[0][n-1] << endl;
    return 0;
}


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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

const int N = 1e3 + 10 ;

char v[N][N] ;
int n , m ;

void read ()
{
    cin >> n >> m ;

    for ( int i = 1 ; i <= n ; i ++ )
    {
        for ( int j = 1 ; j <= m ; j ++ )
            cin >> v[i][j] ;
    }
}

ll dp[N][N] ;

void hard_code_row ()
{
    for ( int j = 1 ; j <= m ; j ++ )
    {
        if ( v[1][j] == '.' )
            dp[1][j] = 1 ;

        else break ;
    }
}

void hard_code_col ()
{
    for ( int i = 1 ; i <= n ; i ++ )
    {
        if ( v[i][1] == '.' )
            dp[i][1] = 1 ;

        else break ;
    }
}

void solve ( int test_case )
{
    read () ;

    if ( v[1][1] == '#' ) { cout << 0 ; line ; return ; }
    dp[1][1] = 1 ;

    hard_code_row () ;
    hard_code_col() ;

    for ( int i = 2 ; i <= n ; i ++ )
    {
        for ( int j = 2 ; j <= m ; j ++ )
        {
            if ( v[i][j] != '.' ) C ;

            dp[i][j] += dp[i][j - 1] + dp[i - 1][j] ;
            dp[i][j] %= mod ;
        }
    }

    cout << dp[n][m] ;
}

int main()
{fast
    int t = 1;
    // cin >> t;

    for ( int i=1 ; i <= t ; i ++ ) solve ( i ) ;
    return 0;
}


Measured memory_bytes: 9216
a = input()
b = input()
c = input()

t = 'a'
win = 'A'
while(True):
    if t == 'a':
        if len(a) == 0:
            win = 'A'
            break
        t = a[0]
        a = a[1:]
    elif t == 'b':
        if len(b) == 0:
            win = 'B'
            break
        t = b[0]
        b = b[1:]
    else:
        if len(c) == 0:
            win = 'C'
            break
        t = c[0]
        c = c[1:]

print(win)


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

#define SZ(v) ((int)(v).size())
using ll = long long;

template<const int32_t MOD>
struct ModInt {
	long long x;
	ModInt() : x(0) {}
	ModInt(long long u) : x(u) {}
	ModInt& operator = (const ModInt &m) { x = m.x; return *this; }
	friend bool operator == (const ModInt& a, const ModInt& b) { return a.x == b.x; }
	friend bool operator != (const ModInt& a, const ModInt& b) { return a.x != b.x; }
	friend bool operator < (const ModInt& a, const ModInt& b) { return a.x < b.x; }
	friend bool operator > (const ModInt& a, const ModInt& b) { return a.x > b.x; }
	friend bool operator <= (const ModInt& a, const ModInt& b) { return a.x <= b.x; }
	friend bool operator >= (const ModInt &a, const ModInt& b) { return a.x >= b.x; }
	static ModInt sign(long long k) { return ((k & 1) ? ModInt(MOD-1) : ModInt(1)); }

 
	ModInt& operator += (const ModInt& m) { x += m.x; if(x >= MOD) x -= MOD; return *this; }
	ModInt& operator -= (const ModInt& m) { x -= m.x; if(x < 0LL) x += MOD; return *this; }
	ModInt& operator *= (const ModInt& m) { x = (1LL * x * m.x) % MOD; return *this; }
	
	friend ModInt operator - (const ModInt& a) { ModInt res(a); if(res.x) res.x = MOD - res.x; return res; }
	friend ModInt operator + (const ModInt& a, const ModInt& b) { return ModInt(a) += ModInt(b); }
	friend ModInt operator - (const ModInt& a, const ModInt& b) { return ModInt(a) -= ModInt(b); }
	friend ModInt operator * (const ModInt& a, const ModInt& b) { return ModInt(a) *= ModInt(b); }
	
	static long long fp(long long u, long long k) {
		long long res = 1LL;
		while(k > 0LL) {
			if(k & 1LL) res = (res * u) % MOD;
			u = (u * u) % MOD;
			k /= 2LL;
		}
		return res;
	}
	
	ModInt fastpow(long long k) { return ModInt(fp(x, k)); }
	ModInt inv() { return ModInt(fp(x, MOD-2)); }
	ModInt& operator /= (const ModInt& m) { return *this *= ModInt(m).inv(); }
	friend ModInt operator / (const ModInt& a, const ModInt& b) { return ModInt(a) *= ModInt(b).inv(); }
 
	friend ostream& operator << (ostream& out, const ModInt& a) { return out << a.x; }
};

using Mint = ModInt<998244353>;

const int MAXN = 3e5;
Mint fact[MAXN], inv[MAXN];

void calc_fact(void)
{
	fact[0] = inv[0] = 1;
	for (int i(1); i < MAXN; ++i)
	{
		fact[i] = i * fact[i-1];
		inv[i] = 1/fact[i];
	}
}

Mint binom(int n, int k)
{
	return fact[n] * inv[n-k] * inv[k];
}

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

	calc_fact();
	int N, M, K;
	cin >> N >> M >> K;	

	Mint ans(0);
	for (int i(0); i <= K; ++i)
		ans += binom(N-1, i) * M * Mint(M-1).fastpow(N-1-i);
	cout << ans << endl;
}


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

#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl

typedef long long ll;

using namespace std;

void solve() {
    int N;
    cin >> N;
    vector<int> D(N);
    REP(i, N) cin >> D[i];

    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            ans += D[i] * D[j];
        }
    }
    print(ans);
}

signed main() {
    solve();
}


Measured memory_bytes: 256
s = str(input())
if s == "SSS":
    print(0)
elif s == "SSR" or s == "SRS" or s == "RSS" or s == "RSR":
    print(1)
elif s == "SRR" or s == "RRS":
    print(2)
elif s == "RRR":
    print(3)


Measured memory_bytes: 9080
#include <iostream>
using namespace std ;
int main()
{
int a,b;
cin>>a>>b;
a,b>-100&&a,b<100;
if((a+b)>=(a-b)&&(a+b)>=(a*b))
{
    cout<< a+b ;
}
else if ((a-b)>=(a+b)&&(a-b)>=(a*b))
{
    cout<<a-b;
}
else if ((a*b)>=(a+b)&&(a*b)>=(a-b))
{
    cout<<a*b ;

}
}


Measured memory_bytes: 256
N, M = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(M):
    A, B = map(int, input().split())
    G[A - 1].append(B - 1)
    G[B - 1].append(A - 1)

path, ans = [[0]], 0
while len(path) > 0:
    p = path.pop()
    if len(p) == N:
        ans += 1
    else:
        for g in G[p[-1]]:
            if not g in p:
                path.append(p + [g])

print(ans)


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

#define int long long
#define pii pair<int, int>
#define pb push_back

signed main(){

    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    string s;
    cin >> s;
    bool found = 0;
    for(auto x: s){
        found |= (x == '7');
    }
    if(found){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
    

    return 0;
}

Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {

    private static Scanner sc;

    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
            int N = sc.nextInt();
            int Y = sc.nextInt();

            int SEN = 1000;
            int GOSEN = 5000;
            int MAN = 10000;

            int z = -1; //1000
            int y = -1; //5000
            int x = -1; //10000


            for(int k=0; k<N+1; k++) {
                for(int j=0; k+j<N+1; j++) {
                    int i = N - (k + j);
                    if(Y == i*MAN+j*GOSEN+k*SEN) {
                        x = i; y = j; z = k;
                    }
                }
            }
            System.out.println(x + " " + y + " " + z);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 22612
from math import sin, cos, radians

A, B, H, M = map(int, input().split())

angleH = radians(90 - H / 12 * 360 - M / 60 * 30)
angleM = radians(90 - M / 60 * 360)
Hx, Hy = A * cos(angleH), A * sin(angleH)
Mx, My = B * cos(angleM), B * sin(angleM)

print(((Hx - Mx)**2 + (Hy - My)**2)**(0.5))


Measured memory_bytes: 9504
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    string s,t="abc";
    cin>>s;
    sort(s.begin(),s.end());
    if(s==t)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}


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

int main() {
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int ans = 0;
    for (int i=0; i<=a; ++i){
        for (int j=0; j<=b; ++j){
            for (int k=0; k<=c; ++k){
                int total = 500*i + 100*j + 50*k;
                if(total == x){
                    ++ans; 
                } 
            }
        }
    }
    cout << ans << endl;
}


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

int main()
{
    int n,i,a;
    cin>>n;
    vector<int>v;
    vector<int>v1;
    vector<int>v2;
    for(i=1; i<=n; i++)
        v.push_back(i);
    for(i=1; i<=n; i++)
    {
        cin>>a;
        v1.push_back(a);
    }
    for(i=1; i<=n; i++)
    {
        cin>>a;
        v2.push_back(a);
    }
    int cnt=1;
    int be=0;
    int fe=0;
    int x=0;
    int y=0;
    do
    {
        for(i=0; i<n; i++)
        {
            if(v[i]==v1[i])
                x++;
        }

        for(i=0; i<n; i++)
        {
            if(v[i]==v2[i])
                y++;
               // cout<<v[i]<<" "<<v2[i]<<endl;
        }
        if(x == v.size())
            be=cnt;
        if(y == v.size())
            fe=cnt;
           // cout<<y<<endl;
        x=0;
        y=0;
        cnt++;


    }while(next_permutation(v.begin(),v.end()));
   // cout<<be<<" "<<fe<<endl;

    cout<<abs(be-fe)<<endl;
}













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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO  cout << "NO"  << endl
#define No  cout << "No"  << endl

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int X; cin >> X;
    int pos = 0, time = 0;

    while(true)
    {
        time++;
        pos += time;
        if(pos >= X)
        {
            cout << time << endl;
            return;
        }
    }
}
    
int main() 
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

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

int main() {
  ll K;
  cin >> K;
  ll ans = 0;
  for (ll i = 1; i <= K; i++) {
    for (ll j = i; j <= K; j++) {
      for (ll k = j; k <= K; k++) {
        for (ll l = 1; l <= i; l++) {
          if (i%l == 0) {
            ll gcd = i/l;
            if (j%gcd == 0 && k%gcd == 0) {
              if (i == j && j == k) {
                ans += gcd;
                break;
              }
              else if (i == j || j == k) {
                ans += gcd*3;
                break;
              }
              else {
                ans += gcd*6;
                break;
              }
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
}

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

int main(){
  int N, total=0;
  
  cin >> N;
  int l,r;
  
  for (int i=0;i<N;i++){
    cin >> l >> r;
    
    total += r-l+1;
  }
  
  cout << total << endl;
}

Measured memory_bytes: 3588
s = input()
flag = True
for i in range(len(s)):
    if s[i] == 'R' and i % 2 == 1:
        flag = False
    if s[i] == 'L' and i % 2 == 0:
        flag = False
if flag:
    print('Yes')
else:
    print('No')

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

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1001001001;
const double PI = acos(-1);

#define rep(i, n)  for(int i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()

int main() {
    long double a, b;
    cin >> a >> b;
    ll ans = (ll)(a*b);
    cout << ans << endl;
}


Measured memory_bytes: 3748
fn main() {
    let (n, k) = read_tuple();
    let pn = read_vec();
    // let mut sum_i = vec![0; n + 1];
    // for i in 1..(n + 1) {
    //     sum_i[i] = sum_i[i - 1] + i;
    // }

    let mut temp_sum: f64 = pn.iter().take(k).map(|p| calc_e(*p)).sum();
    let mut max_sum = temp_sum;
    for i in k..n {
        temp_sum += calc_e(pn[i]);
        temp_sum -= calc_e(pn[i - k]);

        if max_sum < temp_sum {
            max_sum = temp_sum;
        }
    }

    println!("{:?}", max_sum);
}

fn calc_e(p: i64) -> f64 {
    (1..(p+1)).sum::<i64>() as f64 / p as f64   
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_tuple<T: std::str::FromStr + Copy>() -> (T, T) {
    let temp = read_vec();
    (temp[0], temp[1])
}



Measured memory_bytes: 8444
N=int(input())
S=input()

tmp=0
w=[]
for s in S:
  if s=='W': tmp+=1
  w.append(tmp)

tmp=0
e=[]
for s in S[::-1]:
  if s=='E': tmp+=1
  e.append(tmp)
e=e[::-1]

ans=[]
for i in range(N):
  ans.append(w[i]+e[i]-1)
print(min(ans))

Measured memory_bytes: 30828
package main

import (
    "fmt"
    "bufio"
    "os"
)

func main(){
    r := bufio.NewReader(os.Stdin)
    var a, b, c int
    
    fmt.Fscan(r, &a, &b, &c)
    
    if a < b && b < c {
        fmt.Println("Yes")
    } else {
        fmt.Println("No")
    }
}


Measured memory_bytes: 1128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

string S;
ll K;

struct Block {
  char c;
  int n;
};

int main() {
  cin >> S >> K;

  vector<Block> B;
  int i = 0;
  while (i < S.size()) {
    char c = S[i++];
    int n = 1;
    while (i < S.size() && S[i] == c) {
      ++n;
      ++i;
    }
    B.push_back(Block{S[i - 1], n});
  }

  ll ans = 0;
  if (B.size() == 1) {
    ans = (B[0].n * K) / 2;
  } else if (B[0].c == B[B.size() - 1].c) {
    for (int i = 1; i < B.size() - 1; ++i) {
      ans += B[i].n / 2;
    }
    ans *= K;
    ans += ((B[0].n + B[B.size() - 1].n) / 2) * (K - 1);
    ans += B[0].n / 2 + B[B.size() - 1].n / 2;
  } else {
    ans = 0;
    for (auto& b : B) ans += b.n / 2;
    ans *= K;
  }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin >> s;
  cin >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(t>s) cout << "Yes";
  else cout << "No";
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};


int main(){

  ll res = 0;
  int n,m;
  cin >> n >> m;
  map<int,P> mp;
  mp[0] = make_pair(1,1);
  REP(i,n)if(i)mp[i] = make_pair(0,1);
  REP(i,m){
    int x,y;cin >> x >>y;
    x--,y--;
    if(mp[x].second > 1 && mp[x].first){
      mp[x].second--;
      mp[y].first = 1,mp[y].second++;
    }else if(mp[x].second == 1 && mp[x].first){
      mp[x].second--,mp[x].first--;
      mp[y].second++,mp[y].first = 1;
    }else{
      mp[x].second--;
      mp[y].second++;
    }
  }
  REP(i,n)if(mp[i].first)res++;
  cout << res << endl;


  return 0;
}


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

int main()
{
    int a,b,c;
    int m,n;
    a = b = c = 0;
    m = n = 0;
    scanf("%d %d %d",&a,&b,&c);
    if(a == 5)m++;
    else if(a == 7)n++;
    if(b == 5)m++;
    else if(b == 7)n++;
    if(c == 5)m++;
    else if(c == 7)n++;
    if(m == 2 && n == 1)printf("YES");
    else printf("NO");
    return 0;
}


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

Measured memory_bytes: 1024
#include <stdio.h>
 
int    main( void )
{
    int N, K, i, digit=0, n;
    
    scanf("%d %d", &N, &K);
    
    n=N;
    
    for(i=0; i<1000; i++){
        if(n/K!=0){
            digit=digit+1;
            n=n/K;
        }else{
            digit=digit+1;
            break;
        }
    }
    
    printf("%d", digit);
    
    return 0;
}


Measured memory_bytes: 128