akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	const int mod = 1e9 + 7;
	int n, m; cin >> n >> m;
	vi s(n), t(m);
	rep(i, n) cin >> s[i];
	rep(i, m) cin >> t[i];
	
	vector<vi> dp(n + 1, vi(m + 1));
	dp[0][0] = 1;
	
	rep(i, n){
		int sum = 0;
		rep(j, m + 1){
			(dp[i + 1][j] += dp[i][j]) %= mod;
			(sum += dp[i][j]) %= mod;
			if(j < m && s[i] == t[j]) (dp[i + 1][j + 1] += sum) %= mod;
		}
	}
	
	//rep(i, n + 1) dbg(i, dp[i]);
	
	cout << accumulate(all(dp[n]), 0ll) % mod << endl;
	return 0;
}

Measured memory_bytes: 16000
#include<iostream>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    if(i+1>k)
    {
      if(a[i-k]>=a[i])
        cout<<"No"<<endl;
      else
        cout<<"Yes"<<endl;
    }
  }
  return 0;
}

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

int main() {
	int k, n;
	string s;
	cin >> n >> s >> k;
	char hoge = s.at(k-1);
	for (auto &&i = s.begin(); i < s.end(); i++) {
		if (*i != hoge) {
			*i = '*';
		}
	}
	cout << s<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long LL;
const int MAXN = 10000 + 10;
int a[MAXN];
int main() {
    LL cnt1 = 0, cnt2 = 0;
    int n, val;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> val;
        if (val > a[i]) {
            cnt1 += (val - a[i]) / 2;
        }
        else if (val < a[i]) {
            cnt2 += a[i] - val;
        }
    }
    if (cnt1 >= cnt2) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;

/* --------------------------------------------------- */

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(ALL(a), greater<int>());

    ll ans = 0;
    ans += a[0];
    int cnt = 0;
    if(n == 2) {
        cout << ans << endl;
        return 0;
    }
    rep(i, n - 1) {
        ans += a[i + 1];
        cnt++;
        if(cnt + 1 <= n - 2) {
            ans += a[i + 1];
            cnt++;
        }
        if(cnt >= n - 2) break;
    }
    cout << ans << endl;

    return 0;
}

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

int N, P;
vector<int> A;
int dp[51][2];

int dfs(int n, int m) {
  if ( n == N ) {
    if ( m == P ) return 1;
    else return 0;
  }

  if ( dp[n][m] >= 0 ) return dp[n][m];
  int ret = dfs(n+1, (m+A[n])%2) + dfs(n+1, m);
  return dp[n][m] = ret;  
}

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

  cin >> N >> P;
  A.resize(N);
  REP(i, N) cin >> A[i];

  fill_n(*dp, 51*2, -1);
  cout << dfs(0, 0) << endl;

  return 0;
}


Measured memory_bytes: 3632
# imos 法
N, K, Q = map(int, input().split())

score = [0] * N
score[0] = K
for _ in range(Q):
    A = int(input())
    if A == 1:
        score[1] -= 1
    elif A == N:
        score[0] -= 1
        score[N - 1] += 1
    else:
        score[0] -= 1
        score[A - 1] += 1
        score[A] -= 1

for i in range(1, N):
    score[i] += score[i - 1]

for v in score:
    if v > 0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 7856
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<complex>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

char ans[110][110];
int n;

bool isSpace(int x, int y){
  if(x < 0 || y < 0) return true;
  if(x >= n|| y >=n) return true;
  return ans[y][x] == ' ';
}

int main(){
  int d; cin>>d;
  int cc = 0;
  while(d --> 0){
    cin>>n;
    if(cc++ != 0) puts("");
    if(n == 1){
      puts("#");
    }else if(n == 2){
      puts("##");
      puts("# ");
    }else{
      const int dx[4] = {0,1,0,-1};
      const int dy[4] = {-1,0,1,0};
      memset(ans, '#', sizeof(ans));
      REP(i,n) ans[i][n] = '\0';
      int i = 0;
      int x = 1;
      int y = n-1;
      ans[y][x] = ' ';
      while(true){
        if(isSpace(x + dx[i], y + dy[i]) ||
           isSpace(x + dx[i] + dx[i], y + dy[i] + dy[i]))
          break;

        while(!isSpace(x + dx[i] + dx[i], y + dy[i] + dy[i])){
          x = x + dx[i]; y = y + dy[i];
          ans[y][x] = ' ';
        }

        i = (i + 1) % 4;
      }
      REP(i,n) puts(ans[i]);
    }
  }
  return 0;
}

Measured memory_bytes: 0
fun main() {
    val n = readLine()!!.toInt()
    val resultMap = IntArray(n + 1) { 0 }

    for (a in 1..100) {
        if (a * a + 1 * 1 + 1 * 1 + a + 1 + a > n) continue
        for (b in 1..100) {
            if (a * a + b * b + 1 * 1 + a * b + b + a > n) continue
            for (c in 1..100) {
                val count = a * a + b * b + c * c + a * b + b * c + c * a
                if (count <= n) {
                    resultMap[count] += 1
                }
            }
        }
    }

    resultMap.takeLast(n).forEach { println(it) }
}

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

#define ff first
#define ss second
#define int long long
#define pb push_back
#define mp make_pair
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 100000000
#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)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int lis(int* input,int n){
    int *output=new int[n];
    output[0]=1;
    for(int i=1;i<n;i++){
        //traversing in reverse
        output[i]=1;
        for(int j=i-1;j>=0;j--){
            if(input[j]>input[i]){
                continue;
            }
            int posAns=output[j]+1;
            if(posAns>output[i]){
                output[i]=posAns;

            }
        }
    }
    int best=0;
    for(int i=0;i<n;i++){
        if(best<output[i]){
            best=output[i];
        }
    }
    delete [] output;
    return best;
}

int32_t main()
{

	FIO;
	int n,m;
  	cin >>n>>m;
  cout<<(n*(m*100))/100;
	 
}


Measured memory_bytes: 3536
#include <stdio.h>

typedef struct pair* ppair;

typedef struct pair {
  int first, second;
} pair;


int size;
pair v[1000000];
int psize;
pair preorder[1000000];
int sorted;

void swap(ppair a, ppair b) {
  pair t = *a;
  *a = *b;
  *b = t;
}

int getp(int begin, int end) {
  int i;
  int p = begin;
  for(i = begin+1; i < end; ++i) {
    if(v[i].first < v[p].first) {
      p = i;
    }
  }
  swap(&v[end-1], &v[p]);
  return end-1;
}

void qsort(int begin, int end) {
  int i, j;
  if(begin >= end) return;
  getp(begin,end);
  preorder[psize++] = v[end-1];
  if(begin+1 == end) return;
  for(i = begin, j = begin; i < end; ++i) {
    if(v[i].second < v[end-1].second) {
      swap(&v[i], &v[j++]);
    }
  }
  swap(&v[j],&v[end-1]);
  qsort(begin, j);
  qsort(j+1, end);
}

int binary_search(int k) {
  int l, r;
  l = 0;
  r = size;
  while(l < r) {
    int m = (l+r)/2;
    if(v[m].second == k) {
      return m;
    } else if(v[m].second < k) {
      l = m+1;
    } else {
      r = m;
    }
  }
  return -1;
}

int main() {
  int i, j;
  int n, k;
  char s[100];
  size = 0;
  sorted = 0;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    scanf("%s", s);
    if(s[0] == 'i') {
      scanf("%d", &k);
      v[size] = (pair){size,k};
      ++size;
      sorted = 0;
    } else if(s[0] == 'p') {
      if(!sorted) {
        psize = 0;
        qsort(0, size);
        sorted = 1;
      }
      for(j = 0; j < size; ++j) {
        printf(" %d", v[j].second);
      }
      printf("\n");
      for(j = 0; j < size; ++j) {
        printf(" %d", preorder[j].second);
      }
      printf("\n");
    } else {
      scanf("%d", &k);
      if(!sorted) {
        psize = 0;
        qsort(0, size);
        sorted = 1;
      }
      printf(binary_search(k)!=-1?"yes\n":"no\n");
    }
  }
  return 0;
}


Measured memory_bytes: 7992
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
ll gcd(ll x, ll y) {
	if (x < y)swap(x, y);
	if (y == 0)return abs(x - y);
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;
ll mypow(ll x, ll n, ll m) {
	if (n == 0) {
		return 1;
	}
	if (n % 2 == 0) {
		return mypow(x*x%m, n / 2, m);
	}
	else {
		return x * mypow(x, n - 1, m) % m;
	}
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
//テーブルをつくる前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;//mod pにおける1,2,,,nの逆元
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i%INF;
		inv[i] = INF - inv[INF%i] * (INF / i) % INF;
		finv[i] = finv[i - 1] * inv[i] % INF;
	}
}

ll COM(int n, int k) {
	if (n < k)return 0;
	if (n < 0 || k < 0)return 0;
	return fac[n] * (finv[k] * finv[n - k] % INF) % INF;
}
///////////////////////////////////////

int main() {
	int n, m; cin >> n >> m;
	vector<int>a;
	int sum = 0;
	REP(i, n) {
		int v; cin >> v;
		sum += v;
		a.push_back(v);
	}
	if (sum % (4 * m) == 0) {
		sum /= (4 * m);
	}
	else {
		sum /= (4 * m);
		sum += 1;
	}
	sort(a.begin(), a.end(), greater<int>());
	if (a[m - 1] < sum) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#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()
typedef long long ll;

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



int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i,n){
        cin >> a[i];
    }
    string ans = "APPROVED";
    REP(i,n){
        if(a[i]%2 == 0){
            if(a[i]%3 != 0 and a[i]%5 != 0){
                ans = "DENIED";
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass : Scanner
{
    static void Main()
    {
        int N = RInt();
        var A = RLongs();
        
        var dp = new long[N];
        dp[0] = 1000;
        for (int i = 0; i < N-1; i++)
        {
            long tickets = dp[i] / A[i];
            long left = dp[i] % A[i];
            for (int j = i+1; j < N; j++)
            {
                dp[j] = Math.Max(dp[j], Max(left + tickets * A[j], dp[i]));
            }
            
        }
        WriteLine(dp.Max());
    }
}

class Scanner
{
    public static int RInt() => int.Parse(Console.ReadLine());
    public static long RLong() => long.Parse(Console.ReadLine());
    public static string RString() => Console.ReadLine();
    public static double RDouble() => double.Parse(Console.ReadLine());

    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static string[] RStrings() => Console.ReadLine().Split();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static T1 ReadStream<T1>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        return r1;
    }
    public static (T1, T2) ReadStream<T1, T2>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        return (r1, r2);
    }
    public static (T1, T2, T3) ReadStream<T1, T2, T3>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        return (r1, r2, r3);
    }
    public static (T1, T2, T3, T4) ReadStream<T1, T2, T3, T4>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        var r4 = (T4)Convert.ChangeType(r[3], typeof(T4));
        return (r1, r2, r3, r4);
    }
}

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

int main() {
 ll tate,yoko;
 cin >> tate >>yoko;
  
ll ans=0;
  if(yoko==1||tate==1)
  {ans = 1;}
  //よこが偶数なら1セットとして捉える
  else if(yoko%2==0)
  {ans = tate*yoko/2;}

  //よこが奇数なら1セット+1として捉える
  else if(yoko%2==1)
  {yoko--;
    ans = tate*yoko/2;
    ans += (tate + 2 - 1) / 2;
    }

  cout << ans << endl;

  return 0;
}
//vector <int> a(3);

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;
 
 //In Contest Submission//
 /*
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long  a,b,c;
    cin >> a>>b>>c;
    if(sqrt(static_cast<long double>(a))+sqrt(static_cast<long double>(b))<sqrt(static_cast<long double>(c)))cout<<"Yes";
    else cout<<"No";
    }
*/

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long double eps = 1e-14;

    long double a,b,c;
    cin >> a>>b>>c;

    if(sqrtl(a)+sqrtl(b)+eps<sqrtl(c))cout << "Yes";
    else cout << "No";
    }

//
/*
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c;
    cin >> a>>b>>c;
    ll d = (c-a-b);
    if(d>0 && d*d > 4*a*b)cout <<"Yes"<<endl;
    else cout << "No"<<endl;
}
*/

Measured memory_bytes: 256
#include <stdio.h>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;

const int N=60000;
int pr[N];

int main(void){
  REP(i,2,N)pr[i]=1;
  REP(i,2,N){
    if(pr[i])for(int j=2*i;j<N;j+=i)pr[j]=0;
  }
  int n;
  scanf("%d",&n);
  int pos=2;
  while(n>0){
    while(pos%10!=1||pr[pos]==0)pos++;
    printf("%d%c",pos,n==1?'\n':' ');
    pos++;
    n--;
  }
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <set>
#include <map>
#define LL long long int
using namespace std;

int main()
{
   string s;
   cin>>s;
   s[5]=' ';
   s[13]=' ';
   cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<=n;i++)
#define per(i,n,k) for(int i=n;i>=k;i--)
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define ll long long
using namespace std;
const int maxn=100005;
const ll INF=(ll)100000000009;
ll f[maxn];
ll n,w,ans;
int main()
{
	fill(f,f+maxn,INF);
	f[0]=0;
	cin>>n>>w;
	rep(i,0,n-1)
	{
		int x,y;
		cin>>x>>y;
		per(j,100000,y)
		{
			f[j]=min(f[j],f[j-y]+x);
		}
	}
	rep(i,0,100000)
	{
		if(f[i]<=w)
		{
			ans=i;
		}
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
void allcout(auto V) {
    for(auto x : V) cout << x << ' ';
    cout << endl;
}
signed main() {
    int N;
    cin >> N;
    int a[3 * N];
    rep(i, 3 * N) cin >> a[i];
    vector<int> left(N + 1), right(N + 1);
    multiset<int> S;
    int sum = 0;
    rep(i, N) {
        S.insert(a[i]);
        sum += a[i];
    }
    left[0] = sum;
    for(int i = N; i <= 2 * N - 1; i++) {
        int m = *S.begin();
        if(a[i] > m) {
            sum = sum - m + a[i];
            S.erase(S.begin(), ++S.begin());
            S.insert(a[i]);
        }
        left[i - N + 1] = sum;
    }
    multiset<int> SS;
    sum = 0;
    for(int i = N * 3 - 1; i >= N * 2; i--) {
        SS.insert(a[i]);
        sum += a[i];
    }
    right[N] = sum;
    for(int i = N * 2 - 1; i >= N; i--) {
        int m = *(--SS.end());
        if(a[i] < m) {
            sum = sum - m + a[i];
            SS.erase(--SS.end(), SS.end());
            SS.insert(a[i]);
        }
        right[i - N] = sum;
    }
    int ans = -INF;
    rep(i, N + 1) ans = max(ans, left[i] - right[i]);
    cout << ans << endl;
}


Measured memory_bytes: 13568
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    string s;
    cin>>s;
    string st[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    for(ll i=0;i<7;i++){
        if(s==st[i]){
            cout<<7-i<<endl;
        }
    }
    return 0;
}

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

int num[100];
int main()
{
    int n,key;
    scanf("%d",&n);
    for(int i = 0 ; i < n ; i++)
        scanf("%d",&num[i]);
    for(int i = 0 ; i < n ; i++)
    {
        key=num[i];
        int j  = i - 1;
        while(j>=0 && num[j]>key)
        {
            num[j+1]=num[j];
            j--;
            num[j+1]=key;
        }
        for(int i = 0 ; i < n ; i++)
        {
            printf("%d",num[i]);
            if(i<n-1)
            printf(" ");
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 3208
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n,m,x,y;
    cin >> n >> m >> x >> y;
    vi xv(n), yv(m);
    rep(i,n) cin >> xv.at(i);
    rep(i,m) cin >> yv.at(i);
    xv.push_back(x);
    yv.push_back(y);
    sort(xv.begin(), xv.end());
    sort(yv.begin(), yv.end());
    if(xv.at(n) < yv.at(0)){
        cout << "No War" << endl;
    }else{
        cout << "War" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int a,b;
  cin>>a>>b;
  if(a==b){
    cout<<1<<endl;
    return 0;
  }
  Int s=62;
  while((a>>s)==(b>>s)) s--;
  Int ms=(1LL<<s)-1;
  Int c=((b>>s)<<s)|(a&ms);
  Int d=b|ms;

  Int flg=0;
  for(Int i=s-1;i>=0;i--){
    if((b>>i)&1) flg=1;
    b|=(flg<<i);
  }
  
  //cout<<c<<" "<<d<<endl;
  if(c<=b) c=b+1;
  if(d<c) d=c-1; 
  //cout<<a<<" "<<b<<":"<<c<<" "<<d<<endl;
  cout<<(b-a+1)+(d-c+1)<<endl;

  if(0){
    cout<<bitset<61>(a)<<endl;
    cout<<bitset<61>(b)<<endl;
    cout<<bitset<61>(ms)<<endl;
    cout<<bitset<61>(c)<<endl;
    cout<<bitset<61>(d)<<endl;

    set<Int> ans;
    for(Int i=a;i<=b;i++) ans.emplace(i);
    for(Int i=a;i<=b;i++){
      set<Int> nxt;
      for(Int x:ans) nxt.emplace(x|i);
      for(Int x:nxt) ans.emplace(x);
    }
    cout<<"num:"<<ans.size()<<endl;
    for(Int x:ans) cout<<x<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using static System.Console;
using static System.Math;

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve();
        }

        public void Solve()
        {
            MyInputStream cin = new MyInputStream();

            var a = cin.ReadInt();
            var ope = cin.Read()[0];
            var b = cin.ReadInt();

            if (ope == '+')
            {
                WriteLine(a + b);
            } else {
                WriteLine(a - b);
            }
        }
    }

    public class MyInputStream
    {
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(char separator = ' ')
        {
            this.separator = separator;
            inputStream = new Queue<string>();
        }

        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = Console.ReadLine().Split(separator);
            for (int i = 0; i < tmp.Length; i++)
            {
                inputStream.Enqueue(tmp[i]);
            }
            return inputStream.Dequeue();
        }
        public string ReadLine() => Console.ReadLine();
        public int ReadInt() => int.Parse(Read());
        public long ReadLong() => long.Parse(Read());
        public double ReadDouble() => double.Parse(Read());
    }

    public class Pair<T1, T2>
    {
        public T1 First;
        public T2 Second;
        public Pair() { First = default(T1); Second = default(T2); }
        public Pair(T1 f, T2 s) { First = f; Second = s; }
        public override string ToString() { return "(" + First + ", " + Second + ")"; }
        public override int GetHashCode() { return First.GetHashCode() ^ Second.GetHashCode(); }
        public override bool Equals(object obj)
        {
            if (ReferenceEquals(this, obj)) return true;
            else if (obj == null) return false;
            var tmp = obj as Pair<T1, T2>;
            return (object)tmp != null && First.Equals(tmp.First) && Second.Equals(tmp.Second);
        }
    }

    #region HashMap
    public class HashMap<K, V> : Dictionary<K, V>
    {
        public HashMap() : base() { }
        public HashMap(int cap) : base(cap) { }
        public HashMap(IDictionary<K, V> dictionary) : base(dictionary) { }
        new public V this[K i]
        {
            get
            {
                V v;
                return TryGetValue(i, out v) ? v : base[i] = default(V);
            }
            set { base[i] = value; }
        }
    }
    #endregion
}


Measured memory_bytes: 13268
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: usize = read();
    let b: usize = read();
    let c: usize = read();
    let d: usize = read();

    if a + b > c + d {
        println!("Left");
        return;
    }
    if a + b < c + d {
        println!("Right");
        return;
    }

    println!("Balanced")
}


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

int main(){
    ll N,W;
    cin >> N >> W;
    ll w[N], v[N];
    ll sumV =0;
    ll sumW =0;
    for(int i=0;i<N;i++){
        cin >> w[i] >> v[i];
        sumV += v[i];
        sumW += w[i];
    }
    ll standard = w[0];
    for(int i=0;i<N;i++){
        w[i] -= standard;
    }
    if(W>=sumW){
        cout << sumV << endl;
        return 0;
    }

    ll k =1;
    ll s = sumW - standard *N;
    // cerr <<"s=" << s << endl;
    // 先頭i個からj個を選んだ時の最大値;
    ll dp[N+1][N+1][s+1];
    memset(dp,0,sizeof(dp));
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(i<j){
                continue;
            }
            for(int k=0;k<=s;k++){
                if(w[i] >k){
                    dp[i+1][j+1][k] = dp[i][j+1][k];
                }else{
                    dp[i+1][j+1][k] = max(dp[i][j+1][k],dp[i][j][k-w[i]] + v[i]);
                    // cerr << "w[i]=" << w[i] << endl;
                    // cerr << "i =" << i+1 << "j=" << j+1 << "k=" << k <<"val="<<dp[i+1][j+1][k] << endl;
                }
            }
        }
    }

    ll ans =0;
    ll mx = W/standard;
    for(int i=0;i<=mx;i++){
        ll remain = W - standard *i;
        if(remain>s){
            ans = max(dp[N][i][s],ans);
           
        }else{
            ans = max(dp[N][i][remain],ans);
            //  cerr << ans << endl;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 13440
#include <iostream>
#include <vector>

int main(int argc, char *argv[]) {
  int N;
  std::cin >> N;

  double y(0.);
  for (int n = 0; n < N; ++n) {
    double x;
    std::string u;
    std::cin >> x >> u;
    y += (u == "JPY") ? x : (380000. * x);
  }

  std::cout << y << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<cmath>
#include<set>
#include<stack>
#define ll long long
#define pb push_back
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)>(y)?(y):(x))
#define cls(name,x) memset(name,x,sizeof(name))
#define pos first
#define index second
#define mp make_pair
using namespace std;
const int inf=1e9+10;
const ll llinf=1e16+10;
const int maxn=2e5+10;
const int maxm=1e2+10;
const int mod=1e9+7;
int n;
vector<int> v[maxn];
int vis[maxn];
int dist1[maxn];
int dist2[maxn];
void dfs(int s,int d,int dist[])
{
    if(!vis[s]) vis[s]=1;
    else return ;
    dist[s]=d;
    for(int i=0;i<v[s].size();i++)
        dfs(v[s][i],d+1,dist);
}
int main()
{
    //freopen("in.txt","r",stdin);
    while(~scanf("%d",&n))
    {
        for(int i=1;i<=n-1;i++)
        {
            int a,b;
            scanf("%d %d",&a,&b);
            v[a].pb(b);
            v[b].pb(a);
        }
        cls(vis,0);
        dfs(1,0,dist1);
        cls(vis,0);
        dfs(n,0,dist2);
        int ans=0;
        for(int i=1;i<=n;i++)
        {
            if(dist1[i]<=dist2[i])
                ans++;
        }
        //printf("%d\n",ans);
        if(ans>n-ans) printf("Fennec\n");
        else printf("Snuke\n");
    }
    return 0;
}


Measured memory_bytes: 14336
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    N, A, B, C = lr()
    ABC = [A, B, C]
    ans = []
    def ope(u, v):
        ABC[u] += 1
        ABC[v] -= 1
        ans.append(chr(ord('A')+u))
    q = []
    for i in range(N):
        s = sr()
        if s == 'AB':
            x, y = 0, 1
        elif s == 'AC':
            x, y = 0, 2
        else:
            x, y = 1, 2
        q.append([x, y])
    for i in range(N):
        x, y = q[i]
        if ABC[x] == 0 and ABC[y] == 0:
            print('No')
            return
        if ABC[x] == 0:
            ope(x, y)
            continue
        if ABC[y] == 0:
            ope(y, x)
            continue
        if i < N-1:
            nx, ny = q[i+1]
            if x == nx or x == ny:
                ope(x, y)
                continue
        ope(y, x)
    print('Yes')
    print(*ans, sep='\n')
resolve()

Measured memory_bytes: 93224
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;

#define MOD 1000000000 + 7

int gcd(int x, int y)
{
	if (x > y)
	{
		swap(x, y);
	}
	return x ? gcd(x, y % x) : y;
}

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

	cout << gcd(x, y) << endl;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll mod = 1000000007;

void solve()
{
	int n; cin >> n;
	vector<vector<int>> a(2,vector<int>(n));
	rep(i, 2)rep(j, n) cin >> a[i][j];
	vector<vector<int>> s(2,vector<int>(n+1,0));
	rep(i, 2)rep(j, n) s[i][j+1] = s[i][j] + a[i][j];
	int ans = 0;
	rep(i ,n)
	{
		int tmp = s[0][i+1] + (s[1][n] - s[1][i]);
		chmax(ans,tmp);
	}
	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


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

using namespace std;
using ll = long long;
const int INF = 1e9 + 5;
vector<vector<int>> v;
ll dpp[101][100001];

ll dp(ll i, ll w)
{
    if (i == 0 || w == 0)
    {
        dpp[i][w] = 0;
        return dpp[i][w];
    }
    if (dpp[i][w] != -1)
        return dpp[i][w];
    if (v[i - 1][0] <= w)
    {
        dpp[i][w] = max(v[i - 1][1] + dp(i - 1, w - v[i - 1][0]), dp(i - 1, w));
        return dpp[i][w];
    }
    else
    {
        dpp[i][w] = dp(i - 1, w);
        return dpp[i][w];
    }
}

int main()
{
    int n, w;
    cin >> n >> w;
    for (int i = 0; i < n; i++)
    {
        vector<int> k(2);
        for (auto &a : k)
            cin >> a;
        v.push_back(k);
    }
    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= w; j++)
        {
            dpp[i][j] = -1;
        }
    }
    ll ans = dp(n, w);
    cout << ans << "\n";
    return 0;
}


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

int main() {
  string s;
  cin >> s;

  long long Q;
  cin >> Q;

  deque<char> dq;

  for (int i = 0; i < s.length(); i++) dq.push_back(s[i]);

  bool isReversed = false;
  for (long long i = 0; i < Q; i++) {
    int Ti, Fi; char Ci;
    cin >> Ti;

    if (Ti == 1) {
      isReversed = !isReversed;
    }
    else if (Ti == 2) {
      cin >> Fi >> Ci;

      //反転されてない
      if (!isReversed) {
        if (Fi == 1) dq.push_front(Ci);
        if (Fi == 2) dq.push_back(Ci);
      }
      else {
        if (Fi == 1) dq.push_back(Ci);
        if (Fi == 2) dq.push_front(Ci);
      }

    }
  }

  if (!isReversed) {
    for (auto item : dq) cout << item;
  }
  else {
    reverse(dq.begin(), dq.end());
    for (auto item : dq) cout << item;
  }
  cout << endl;
  return 0;
}


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

int main() {
	int64_t n, w;
	cin >> n >> w;
	vector<vector<int64_t>> wv(n+1, vector<int64_t>(2));
	wv.at(0) = { 0,0 };
	for (int i = 1; i <= n; i++)cin >> wv.at(i).at(0) >> wv.at(i).at(1);
	vector<vector<int64_t>> dp(n + 1, vector<int64_t>(w + 1,-1));
	for (int i = 0; i <= w; i++)dp.at(0).at(i) = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= w; j++) {
			if (j < wv.at(i).at(0))dp.at(i).at(j) = dp.at(i - 1).at(j);
			else {
				dp.at(i).at(j) = max(dp.at(i - 1).at(j),
					dp.at(i - 1).at(j - wv.at(i).at(0)) + wv.at(i).at(1));
			}
			//cout << dp.at(i).at(j) << " ";
		}	
		//cout << endl;
	}
	cout << dp.at(n).at(w) << endl;
}

Measured memory_bytes: 80256
A, B = list(int(el) for el in input().split(' '))


if (A==1) or (B==1): 
  print(1) 
  is_print=False
else:
  def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
      if temp%i==0:
        cnt=0
        while temp%i==0:
          cnt+=1
          temp //= i
        arr.append([i, cnt])

    if temp!=1:
      arr.append([temp, 1])

    if arr==[]:
      arr.append([n, 1])

    return arr

  fact_a = factorization(A)
  fact_b = factorization(B)

  set_a = set()
  set_b = set()

  set_a.add(1)
  set_b.add(1)

  for fa, _ in fact_a: set_a.add(fa)
  for fb, _ in fact_b: set_b.add(fb)


  print(len(set_a & set_b))

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


  
int main(){
  

  int n;
  cin>>n;
  

  int c1,c2,c4;
  c1=0;
  c2=0;
  c4=0;
  
  for (int i=0;i<n;i++){
    int tmp;
    cin>>tmp;
    
    if (tmp%4==0){
      c4++;
    }
    
    else if (tmp%4==2){
      c2++;
    }
    
    else {
      c1++;
    }
  }
    
  string answer="No";
    
  if (c1<=c4 or (c1==c4+1 and c1+c4==n)){
    answer="Yes";
  }
    
  cout<<answer<<endl;
    

    
  
  
}

















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

signed main(){
	int N, i;
	scanf("%lld", &N);
	int ans = N;
	for(i = 1; i * i <= N; i++){
		if(N % i == 0){
			ans = min(ans, i + N / i - 2);
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    int n = 0;
    cin >> n;
    vector<ll> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
    }
    for (int i=1; i<n; i++) {
        a.at(i) += a.at(i-1);
    }
    ll ans = 1e12;
    for (int i=0; i<n-1; i++) {
        ll buf = abs(a.at(n-1) - 2*a.at(i));
        ans = min(ans, buf);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
fun main(args: Array<String>){
    val (N, K) = readLine()!!.split(" ").map{ it.toInt() }
    var ans = 0.toDouble()
    for (s in 1..minOf(N, K-1)){
        ans += Math.pow(1 / 2.toDouble(), powerOfTwo(s, K).toDouble())
    }
    if (N >= K){
        ans += N - K + 1
    }
    ans /= N
    println(ans)
}

fun powerOfTwo(s: Int, k:Int):Int{
    var score = s
    var power = 0
    while (score < k){
        score *= 2
        power += 1
    }
    return power
}

fun pow(num: Double, power: Int): Double{
    var n = num
    if (power == 0){ return 1.toDouble() }
    for (i in 0 until power - 1){
        n *= num
    }
    return n
}
fun <T : Comparable<T>> minOf(a: T, b: T): T = if (a<b) a else b

Measured memory_bytes: 35944
#include <stdio.h>
#define max(x, y) (x > y ? x : y)
typedef struct {
    int x;
    int y;
} data_t;
typedef struct {
    int head;
    int tail;
    data_t data[200000];
} queue_t;
queue_t queue;
void init_queue() { queue.head = queue.tail = 0; }
void enqueue(data_t data) { queue.data[queue.tail++] = data; }
data_t dequeue() { return queue.data[queue.head++]; }
int dist[100][100];
int h, w;
char s[100][100];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int bfs(data_t start, data_t end) {
    init_queue();
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            dist[i][j] = -1;
        }
    }
    dist[start.y][start.x] = 0;
    enqueue(start);
    while (queue.tail != queue.head) {
        data_t now = dequeue();
        for (int i = 0; i < 4; i++) {
            data_t move;
            move.x = now.x + dx[i];
            move.y = now.y + dy[i];
            if (move.x < 0 || move.x >= w || move.y >= h || move.y < 0) {
                continue;
            }
            if (s[move.y][move.x] == '#' || dist[move.y][move.x] != -1) {
                continue;
            }

            enqueue(move);
            dist[move.y][move.x] = dist[now.y][now.x] + 1;
        }
    }
    int max = -1;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            max = max(dist[i][j], max);
        }
    }
    return max;
}
int main(void) {
    scanf("%d %d", &h, &w);
    int max = 0;
    for (int i = 0; i < h; i++) {
        scanf("%s", s[i]);
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '#') {
                continue;
            }
            data_t start, end;
            start.y = i;
            start.x = j;
            if (max < bfs(start, end)) {
                max = bfs(start, end);
            }
        }
    }
    printf("%d\n", max);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

class Main{



	public static void main(String[] args) {



		Scanner sc = new Scanner(System.in);			//文字の入力
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int ans =0;

		int aa = 0;
		int bb = 0;
		boolean a = false;
		boolean b = false;



		if(2*C <= A+B){

			while(aa < X && bb < Y){
				ans += 2*C;
				aa++;
				bb++;
				if(aa == X){
					a = true;

				}
				if(bb == Y){
					b = true;
				}

			}

			if(a){
				if(2*C > B){
					while(bb < Y){
						ans += B;
						bb++;
					}
				}else{
					while(bb < Y){
						ans += 2*C;
						bb++;
					}
				}
			}else{
				if(2*C > A){
					while(aa < X){
						ans += A;
						aa++;
					}
				}else{
					while(aa < X){
						ans += 2*C;
						aa++;
					}
				}
			}


		}else{

			while(aa != X){
				ans += A;
				aa++;
			}
			while(bb != Y){
				ans += B;
				bb++;
			}

		}

		System.out.println(ans);


	}

	static long comb(int n,int r){
		long ue = 1;
		for(int i = 0;i < r;i++){
			ue *= n-i;
		}
		long sita = 1;
		for(int i = 1;i <= r;i++){
			sita *= i;
		}
		return ue/sita;


	}





}




class Pair implements Comparable{
	String from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}





Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define rep(i,a,b)  for (int i = a; i < b; ++i)
#define rrep(i,z,a) for (int i = z; i >= a; --i)
#define rep0(n)     for(int i = 0 ; i < n; ++i )
#define rep1(n)     for(int i = 1 ; i <= n; ++i )
#define pb          push_back
#define sd(x)       scanf("%d",&x)
#define tc          int test;cin>>test; while(test--)
#define all(v)      v.begin(),v.end()
#define ff          first
#define ss          second
#define mp          make_pair
#define IOS         ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl        "\n"
#define spc         " "
#define mem0(a)     memset(a,0,sizeof(a))
#define extime      cout << endl << endl << "____"<<(float)clock() / CLOCKS_PER_SEC << "s____";
#define maxn        998244353
#define mod         2000000014
//#define ll          long long int
//typedef vector<ll>  vll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
void OJ()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}
vi adj[200005];
int vis[200005];
int n, m, a, b, cnt, ans;
void dfs(int node)
{
  if (vis[node] == 1)return ;
  vis[node] = 1, cnt++;
  for (auto ch : adj[node])
    if (vis[ch] == 0)dfs(ch);
}
int solve()
{
  cin >> n >> m;
  while (m--)
  {
    cin >> a >> b;
    adj[a].pb(b);
    adj[b].pb(a);
  }
  rep1(n)
  {
    cnt = 0;
    if (vis[i] == 0)dfs(i);
    ans = max(cnt, ans);
  }
  cout << ans;
  return 0;
}
signed main()
{
  OJ();
  IOS
  //tc
  solve();
  //extime
  return 0;
}

Measured memory_bytes: 22276
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
#include <sstream>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vec2bool vector<vector<bool>>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s >= 0;s--)

int main()
{
	ll n;
	string s,ans;
	bool flag = false;

	cin >> n;
	cin >> s;

	if (s.size() > n)
	{
		forll(i, 0, n)
			ans.push_back(s[i]);

		ans.push_back('.');
		ans.push_back('.');
		ans.push_back('.');
	}
	else
		ans = s;

	
	cout << ans;

}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

class UnionFind {
public:
    vector<int> par;
    int num;

    UnionFind(int n) : par(n, -1), num(n) {};

    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }

    int size(int x) {
        return -par[root(x)];
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (size(x) < size(y)) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        num--;
        return true;
    }

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

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    set<int> ng[n] = {};
    UnionFind uf(n);
    int a[m], b[m];
    rep(i, 0, m) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        uf.unite(a[i], b[i]);
    }
    rep(i, 0, m) {
        if (uf.same(a[i], b[i])) {
            ng[a[i]].insert(b[i]);
            ng[b[i]].insert(a[i]);
        }
    }
    rep(i, 0, k) {
        int c, d;
        cin >> c >> d;
        c--;
        d--;
        if (uf.same(c, d)) {
            ng[c].insert(d);
            ng[d].insert(c);
        }
    }
    int ans[n] = {};
    rep(i, 0, n) {
        ans[i] = 0;
        ans[i] += uf.size(i);
        ans[i] -= ng[i].size();
        ans[i]--;
    }
    rep(i, 0, n) cout << ans[i] << " ";
    cout << endl;
    return 0;
}


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


//defines...
#define ll long long
#define tata return;
#define pb push_back
#define mp make_pair
#define in insert
#define run ios_base::sync_with_stdio(false);cin.tie(NULL);
#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
#define vec vector<ll>
#define setl set<ll>
#define mapl map<ll,ll>
#define shunno cout<<0<<endl;
#define pi 2*acos(0.0)1
#define hobena cout<<-1<<endl;








void oka()
{
    double d,t,s;
    cin>>d>>t>>s;
    if(d/s>t)
    {
        no

    }
    else
        yes





}






int main()
{
   //string g="abcd";
    //g.erase(g.begin()+3);
    //cout<<g<<endl;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    run
    ll i,t;
    t=1;
   //cin>>t;


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


    oka();
    }






}

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


int main (){
    int i= 0;
    int s[150000] = {0};
    int n;
    int count = 0;
    int cheak[150000] = {0};
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&s[i]);
    }
    i = s[0];
    cheak[0]++;
    count++;
    while(1){
        if(i == 2){
            
            printf("%d\n",count);
            break;
        }else if(cheak[i] > 1){
            printf("-1\n");
            break;
        }
        i = s[i-1];
        cheak[i]++;
        count++;
        //printf("i = %d\n",i+1);
    }
    return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>

#define MAX (1<<(2*12-3))

void init();
void insert(char *str);
int find(char *str);
int get_key(char *str);

const int hash[] = {
    0  /* A */
    ,0 /* B */
    ,1 /* C */
    ,0 /* D */
    ,0 /* E */
    ,0 /* F */
    ,2 /* G */
    ,0 /* H */
    ,0 /* I */
    ,0 /* J */
    ,0 /* K */
    ,0 /* L */
    ,0 /* M */
    ,0 /* N */
    ,0 /* O */
    ,0 /* P */
    ,0 /* Q */
    ,0 /* R */
    ,0 /* S */
    ,3 /* T */
};

char dic[MAX];

int main(){
    char cmd[7];
    char str[13];
    int n;
    int i;

    init();

    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s %s",cmd,str);
        if(cmd[0]=='i'){
            insert(str);
        }else{
            printf(find(str)?"yes\n":"no\n");
        }
    }

    return 0;
}

void init(){
    int i;
    for(i=0;i<MAX;i++)dic[i]=0;
}

void insert(char *str){
    int key;
    key = get_key(str);
    dic[key>>3]|=0x01<<(key&0x07);
}

int find(char *str){
    int key;
    key = get_key(str);
    return dic[key>>3]&(0x01<<(key&0x07));
}

int get_key(char *str){
    int key;
    int idx;

    key=1;
    for(idx=0;str[idx];idx++){
        key<<=2;
        key+=hash[str[idx]-'A'];
    }

    return key;
}

Measured memory_bytes: 3856
a, b, k = map(int, input().split())

ak = [i for i in range(a, min(b + 1, a + k))]
bk = [i for i in range(max(a, b - k + 1), b + 1)]

answer = list(set(ak) | set(bk))
answer.sort()
print(*answer, sep='\n')


Measured memory_bytes: 3060