akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    ll n, m; cin >> n >> m;
    vector<ll> a(n);
    ll sum = 0;
    for(int i = 0; i < n; ++i){
        cin >> a[i]; sum += a[i];
    }
    sort(a.begin(), a.end(), greater<ll>());
    string ans = "Yes";
    for (int j = 0; j < m; ++j) {
        if(a[j] * (4 * m) < sum) ans = "No";
    }
    cout << ans << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


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

#include <boost/multiprecision/cpp_int.hpp>

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

using namespace std;
using ll=long long;


int main()
{
  int MOD = 1000000007;
  int a,b,c,d,e,f;
  cin >> a>>b>>c>>d>>e>>f;

   double ans = 0;
   int mizu = 0;
   int satto = 0;

   int ii = 0;
   int jj = 0;
   int kk = 0;
   int ll = 0;

   
   for (int i=0;a*i*100<=f;i++){
     for (int j=0; (a*i+b*j)*100<=f; j++){
       if (a*i*100+b*j*100 < f){

	 int res = f - (a*i+b*j)*100;
	 int sato = (a*i+b*j) * e;

	 for (int k=0; c*k<=sato; k++){
	   for (int l=0; d*l+c*k<=sato;l++){
	     if (d*l+c*k<=min(res,sato) ) {
	       if (i>0 || j>0){
		 // cout << i<<j << " sato " << sato << " res " << res << endl;

		 double tmp = double(d*l+c*k)/double((a*i+b*j)*100+d*l+c*k);
		  // cout << k <<" "<< l<<" " <<tmp << endl;
	       if (ans < tmp){	
		   ans = tmp;
		   satto = d*l+c*k;
		   mizu = (a*i+b*j)*100+d*l+c*k;
		   ii = i;
		   jj = j;
		   kk = k;
		   ll = l;
		 }
	       }
	     }
	   }
	 }
       }
       
     }
   }

   
  //cout << x << " " << vec[1] <<" "<< endl;

   //cout << mizu << " " <<satto << ii<<jj<<kk<<ll<<endl;
   if (mizu == satto) mizu = 100 * a;
   cout << mizu << " " <<satto << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int d;
	d = max(max(b, c), a);
	cout << (d*pow(2, k))+a+b+c-d << endl;
}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> cnt(m, 0);
    for (int i = 0; i < n; i++) {
        int K;
        cin >> K;
        for (int j = 0; j < K; j++) {
            int a;
            cin >> a;
            cnt[a-1]++;
        }
    }

    int ans = 0;
    for (int i = 0; i < m; i++) {
        ans += (cnt[i] == n);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
	#define SAY(X) cout << (X) << '\n';
#else
	#define DBG(X)
	#define SAY(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

const int MAXN = 705;
int adj[MAXN][MAXN];
int used[MAXN], color[MAXN];
int cnt[MAXN][2], head = 0;

int n, m;
int bipartite = 1;

int knapsack[MAXN][MAXN];

void dfs(int v, int c) {
	used[v] = 1;
	color[v] = c;
	++cnt[head][c];

	for(int u = 0; u < n; ++u) {
		if(!adj[v][u] && u != v) {
			if(!used[u]) {
				dfs(u, c ^ 1);
			} else {
				bipartite &= (color[v] != color[u]);
			}
		}
	}
}

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

	for(int i = 0; i < m; ++i) {
		int v = fetch<int>() - 1;
		int u = fetch<int>() - 1;

		adj[v][u] = adj[u][v] = 1;
	}

	for(int v = 0; v < n; ++v) {
		if(!used[v]) {
			dfs(v, 0);
			++head;
		}
	}

	DBG(bipartite);
	if(bipartite) {
		knapsack[0][0] = 1;

		for(int i = 0; i < head; ++i) {
			for(int j = 0; j < MAXN; ++j) {
				if(!knapsack[i][j]) {
					continue;
				}

				for(int c = 0; c < 2; ++c) {
					int j2 = j + cnt[i][c];

					if(j2 < MAXN) {
						knapsack[i + 1][j2] = 1;
					}
				}
			}
		}

		int answ = INT_INF;

		for(int a = 0; a < MAXN; ++a) {
			if(knapsack[head][a]) {
				int b = n - a;
				answ = min(answ, (a * (a - 1)) / 2 + (b * (b - 1)) / 2);
				DBG(a); DBG(b);
			}
		}

		cout << answ << '\n';
	} else {
		cout << NIL << '\n';
	}
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;

int main()
{
	string S, T;
	cin >> S >> T;

	int32_t N = S.size();
	map<char, char> _map, _map_r;
	bool res = true;
	for (int32_t i = 0; i < N; i++) {
		if (_map.count(S[i]) < 1) {
			if (_map_r.count(T[i]) < 1) {
				_map[S[i]] = T[i];
				_map_r[T[i]] = S[i];
			} else if (_map_r[T[i]] != S[i]) {
				res = false;
				break;
			}
		} else if (_map[S[i]] != T[i]) {
			res = false;
		}
	}

	cout << (res ? "Yes" : "No") << endl;

	return 0;
}


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

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

  int size = s.size();
  int result_flag = 0;


  for (int i = 0; i < size; i++) {
    for (int j = i + 1; j < size; j++) {
      if (s[i] == s[j]) {
        result_flag = 1;
      }
    }
  }

  if (result_flag == 1) {
    cout << "no" << endl;
  } else {
    cout << "yes" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;

  cin >> n >> k;

  if(k <= n / 2 + n % 2){
	cout << "YES" << endl;
  }else{
	cout << "NO" << endl;
  }
  return 0;
}


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

fn main() {
    let stdin = stdin();
    let mut lock = stdin.lock();
    let mut str1 = String::new();
    lock.read_to_string(&mut str1).unwrap();
    let mut iter1 = str1.trim().split_whitespace();
    let a = usize::from_str(iter1.next().unwrap()).unwrap();
    let _b = usize::from_str(iter1.next().unwrap()).unwrap();
    //let chars: Vec<_> = iter1.next().unwrap().chars().collect();
    let chars = iter1.next().unwrap().chars();
    for (i, item) in chars.enumerate() {
        if a == i {
            if item != '-' {
                println!("No");
                return;
            } else {
                continue;
            }
        }
        if item.is_digit(10) == false {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <utility>
#include <set>
using namespace std;

vector<pair<int, bool>> v(210);
int main() {
	int N; cin >> N;
	for(int i=0; i<N*2; ++i){
	    int a, b;
	    cin >> a >> b;
	    v[a]=make_pair(b, i<N);
	}
	set<int> st;
	int ans=0;
	for(int i=0; i<N*2; ++i){
	    if(v[i].second) st.insert(v[i].first);
	    else{
	        for(int j=v[i].first-1; j>=0; --j){
	            if(st.find(j)!=st.end()){
	                ++ans;
	                st.erase(j);
	                break;
	            }
	        }
	    }
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e9)

ll MOD = 1e9 + 7;

ll mpow(ll a, ll n) {  // a^n (mod MOD)
    // 二分累乗法 O(log n)
    ll ans = 1;
    while (n != 0) {
        if (n & 1) ans = ans * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return ans;
}

vi fac_vec;
ll fac(ll n) {  // n! (mod MOD)
    if (fac_vec.empty()) {
        fac_vec = vi(3e6);  // (3*10^6)! まで対応
        fac_vec[0] = 1;
        for (ll i = 1; i < fac_vec.size(); i++) {
            fac_vec[i] = fac_vec[i - 1] * i % MOD;
        }
    }
    return fac_vec[n];
}

vi ifac_vec;
ll ifac(ll n) {  // (n!)^(-1) (mod MOD)
    // フェルマーの小定理より、k^(-1)≡k^(MOD-2) なので、
    // (n!)^(-1)≡(n!)^(MOD-2)
    if (ifac_vec.empty()) {
        ifac_vec = vi(3e6);  // {(3*10^6)!}^(-1) まで対応
        ifac_vec[0] = 1;
        for (ll i = 1; i < ifac_vec.size(); i++) {
            ifac_vec[i] = ifac_vec[i - 1] * mpow(i, MOD - 2) % MOD;
        }
    }
    return ifac_vec[n];
}

ll comb(ll a, ll b) {  // aCb (mod MOD)
    // aCb = a! * (b!)^(-1) * {(a-b)!}^(-1)
    if (a < b || a < 0 || b < 0) return 0;
    return (ifac(b) * ifac(a - b) % MOD) * fac(a) % MOD;
}

int main() {
    ll N, K;
    cin >> N >> K;

    for (ll i = 1; i <= K; i++) {
        // 青を入れる場所 comb(N - K + 1, i)
        // 青の分け方 comb(K - 1, i-1)
        ll ans = comb(N - K + 1, i) * comb(K - 1, i-1) % MOD;
        cout << ans << endl;
    }
}


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

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

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;

int main() {
  int x,y;
  cin >> x>>y;
  bool b = false;
  if(x==2){
    if(y==2){
      b = true;
    }
  }
  else if(x==4||x==6||x==9||x==11){
    if(y==4||y==6||y==9||y==11){
      b = true;
    }
  }
  else{
    if(y!=2&&y!=4&&y!=6&&y!=9&&y!=11){
      b = true;
    }
  }
  if(b) cout << "Yes" << endl;
  else cout << "No" << endl;
}
      

Measured memory_bytes: 3564
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
use proconio::input;
//use proconio::marker::Usize1;
//use proconio::marker::Chars;
//use std::collections::HashSet;
use std::cmp::*;
//use std::num;

fn main() {
    input! {
        a:i32,b:i32,c:i32,x:i32,y:i32
    }
    let mut ans = 1000000000;
    for z in 0..max(x, y) + 1 {
        // aの枚数
        let x2 = max(0, x - z);
        let y2 = max(0, y - z);
        let z2 = z * 2;
        ans = min(ans, x2 * a + y2 * b + z2 * c);
    }
    println!("{}", ans);
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
void pk()
{
    double d,t,s;
    cin>>d>>t>>s;
    if(d/s<=t)
       cout<<"Yes"<<"\n";
    else cout<<"No";
}
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    //a #ifndef ONLINE_JUDGE 
    // freopen("/home/priyanshu/Hackercup/input.txt", "r", stdin); 
    // freopen("/home/priyanshu/Hackercup/output.txt", "w", stdout); 
    // #endif 
	ll t=1;
   // cin>>t;
    while(t--)
    {
        pk();
    }
} 

Measured memory_bytes: 3728
import Data.List

dif (x:[]) = []
dif (x0:x1:xs) =
  (x0-x1):dif (x1:xs)

a' n1 n2 d =
  let dd = drop (n1-1) $ take (n2) $ zip [1..] $ dif d
      mx = maximumBy (\ (a,b) (c,d) -> if b == d
                                       then compare a c
                                       else compare b d ) dd
      (a,b) = mx
  in
    a

ans ([0,0,0]:_) = []
ans ([m,n1,n2]:x) =
  let d = map (\ [a] -> a) $ take m x
      r = drop m x
  in
    (a' n1 n2 d):ans r    

main = do
  c <- getContents
  let i = map (map read) $ map words $ lines c :: [[Int]]
      o = ans i
  mapM_ print o
  

Measured memory_bytes: 5512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++);
int main(){
    int A, B, C, D; cin >> A >> B >> C >>D;
  	int res = (A*B < C*D)? C*D : A*B;
    cout << res;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        String text = "";
        if(A%3 == 0 || B%3 == 0 || (A+B)%3 == 0){
            text = "Possible";
        }else{
            text = "Impossible";
        }
        System.out.println(text);
     }
}

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

int main() {
	ll N,s=0,r=1e15,t=0;
	cin >> N;
	vector<ll> a(N);
	rep(i,N) {
		cin >> a.at(i);
		s += a.at(i);
	}

	rep(i,N-1) {
		t += a.at(i);
		r = min(r, abs(2*t-s));
	}

	cout << r << endl;
}

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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

const int N = 1e5 + 10;

int n, m;

VI edge[N];

int mxd[N], co[N];

void dfs(int u, int d, int c)
{
	if (d <= mxd[u]) return;
	if (!co[u]) co[u] = c;
	mxd[u] = d;
	for (auto v: edge[u])
		dfs(v, d - 1, c);
}

int v[N], d[N], c[N];

int main()
{
	gii(n, m);
	for (int i = 1; i <= n; ++i) mxd[i] = -1;
	for (int i = 1; i <= m; ++i)
	{
		int u, v;
		gii(u, v);
		edge[u].pb(v);
		edge[v].pb(u);
	}
	int q;
	gi(q);
	for (int i = 1; i <= q; ++i)
		giii(v[i], d[i], c[i]);
	for (int i = q; i; --i)
		dfs(v[i], d[i], c[i]);
	for (int i = 1; i <= n; ++i)
		printf("%d\n", co[i]);
}

Measured memory_bytes: 8440
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int h,w,k;
	cin>>h>>w>>k;
	string s[6];
	for(int i=0;i<h;i++)
		cin>>s[i];
	int ans =0;
	
	for(int i=0;i<(1<<h);i++)
		for(int j=0;j<(1<<w);j++)
		{
			int cnt = 0;
			for(int x = 0;x < h;x++)
				for(int y = 0;y < w;y++)
					if(!(i>>x&1) and !(j>>y&1))
						cnt += s[x][y]=='#';
		
			ans += cnt==k;
		}
		
		
	cout<<ans;
}


Measured memory_bytes: 3596
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

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

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N;
  cin >> N;
  vll X(N);
  REP(i, 0, N) {
    ll x;
    cin >> x;
    X[i] = x;
  }
  sort(X.begin(), X.end());

  ll min = kMod;
  REP(i, X[0], X[X.size() - 1] + 1) {
    ll count = 0;
    REP (j, 0, X.size()) {
      count += (X[j] - i) * (X[j] - i);
    }
    if (min > count) {
      min = count;
    }
  }
  cout << min << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                    \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifndef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
template <typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define prec fixed << setprecision(12)
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for (int i = a; i >= b; i--)
#define test  \
	int t;    \
	cin >> t; \
	while (t--)
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;
int _x[] = {0, 0, -1, 1, -1, 1, -1, 1};
int _y[] = {-1, 1, 0, 0, 1, -1, -1, 1};

int lcm(int a, int b)
{
	return a * b / __gcd(a, b);
}

void solve()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int numdivbyc, numdivbyd, numdivbycd;
	if (a % c == 0)
	{
		numdivbyc = b / c - a / c + 1;
	}
	else
	{
		numdivbyc = b / c - a / c;
	}
	if (a % d == 0)
	{
		numdivbyd = b / d - a / d + 1;
	}
	else
	{
		numdivbyd = b / d - a / d;
	}
	int x = lcm(c, d);
	if (a % x == 0)
	{
		numdivbycd = b / x - a / x + 1;
	}
	else
	{
		numdivbycd = b / x - a / x;
	}
	debug() << imie(numdivbyc) imie(numdivbyd) imie(numdivbycd);
	int total = b - a + 1;
	cout << total - numdivbyc - numdivbyd + numdivbycd;
}

int32_t main()
{
	ios::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cin.tie(NULL);
	// test
	solve();
	return 0;
}


Measured memory_bytes: 3652
def calc(x):
    r = 0
    while x:
        r += x % 10
        x = x // 10
    return r

def solve0(N):
    r = max(calc(i) for i in range(N + 1))
    return r

def solve(N):
    if N < 10:
        return N
    x = N % 10
    if x == 9:
        return solve(N // 10) + x
    else:
        return solve(N // 10 - 1) + 9

N = int(input())

print(solve(N))




Measured memory_bytes: 3316
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()

a = list(input())

if n % 2 != 0:
    print("No")
else:
    for i in range(n//2):
        if a[i] != a[i+n//2]:
            print("No")
            exit()
    else:
        print("Yes")


Measured memory_bytes: 38384
program main
  implicit none

  integer :: d, n, ans

  read(*,*) d, n

  select case(d)
  case(0)
     ans = 1
  case(1)
     ans = 100
  case(2)
     ans = 10000
  end select

  if (n /= 100) then
     ans = ans * n
  else
     ans = ans * 101
  end if

  write(*,*) ans

end program main


  


Measured memory_bytes: 2840
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ph push
#define ptc putchar
#define enter putchar('\n')
#define mod 998244353
using namespace std;
typedef pair<int,int> pii;
typedef double db;
typedef long double ldb;
typedef long long ll;
typedef long long lnt;
inline int read(){
	int x = 0;char c = getchar();
	while (!isdigit(c)) c = getchar();
	while (isdigit(c)) x = (x << 1) + (x << 3) + c - '0' , c = getchar();
	return x;
}
inline void write(int x){
	if (!x){
       ptc('0');
       return;
	}
	int dg[20] , len = 0;
	while (x) dg[len++] = x % 10 , x /= 10;
	while (len--) ptc(dg[len]+'0');
}
inline void writeln(int x){
	write(x);
	ptc('\n');
}
inline int add(int x,int y){
	x += y;if (x >= mod) x -= mod;
	return x;
}
inline int sub(int x,int y){
	x -= y;if (x < 0) x += mod;
	return x;
}
inline int qpow(int x,int y){
	int res = 1;
	while (y){
		if (y & 1) res = 1ll * res * x % mod;
		x = 1ll * x * x % mod;y >>= 1;
	}
	return res;
}
const int N = 2e5 + 10;
int n , a[N];
lnt res;
int main() {
	scanf("%d",&n);
	for (int i = 1;i <= n;i++){
		scanf("%d",a + i);
	}
	if (a[1] != 0) {
		return puts("-1") , 0;
	}
	for (int i = n;i >= 1;i--){
		if (a[i] == 0) continue;
		int j = i;
		while (j - 1 >= 1 && a[j - 1] < a[j]){
			if (a[j - 1] < a[j] - 1) return puts("-1") , 0;
			j--;
		}
		res += a[i];
		
//		printf("%d %d\n",j,i);
		i = j;
	}
	
	cout<<res;
	return 0;
}


Measured memory_bytes: 1024
// inputに入力データ全体が入る
function Main(input) {
    const args = input.split(' ');
	const n = parseInt(args[0], 10);
	const a = parseInt(args[1], 10);
    const b = parseInt(args[2], 10);
	
	var feeTrain = n * a;
    var feeTaxi = b;
	if(feeTrain < feeTaxi){
        console.log(feeTrain);
    } else{
	    console.log(feeTaxi);
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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







int main(){
  

  int a,b,c,k;
  cin>>a>>b>>c>>k;
  
  int answer;
  
  if (k<=a+b){
    answer=min(k,a);
  }
  
  else {
    answer=a-(k-a-b);
  }
  
  cout<<answer<<endl;
  
  
  
  
  
  
  
    
  
  
  
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cassert>
using namespace std;

int n;

int dsum(int x) {
	int ret = 0;
	while (x > 0) {
		ret += x % 10;
		x /= 10;
	}
	return ret;
}

signed main() {
	cin >> n;
	
	int ans = 114514;
	for (int a = 1; a < n; a++) {
		int b = n - a;
		int res = dsum(a) + dsum(b);
		ans = min(ans, res);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 768
#include<stdio.h>

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

int n;
int A[1000];
int B[1000];
int vd[1000];
int cnt,sum,mini;

int min(int x,int y){
  if(x<y)return x;
  else return y;
}

int search(int x){
  int i;
  for(i=0;i<n;i++)if(A[i]==x)return i;
}

int main(){
  int i,j,ans,x;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    B[i]=A[i];
  }

  for(i=n-1;i>0;i--)
    for(j=0;j<i;j++)
      if(B[j]>B[j+1])swap(&B[j],&B[j+1]);
  
  ans=0;
  for(i=0;i<n;i++)vd[i]=0;

  for(i=0;i<n;i++){   
    x=i;
    cnt=sum=0;
    mini=(1<<24);
    while(vd[x]==0){
      vd[x]=1;
      cnt++;
      sum+=A[x];
      mini=min(mini,A[x]);
      x=search(B[x]);
    }
    if(cnt<2)continue;
    ans+=min(sum+B[0]*(cnt+1)+mini,sum+mini*(cnt-2));

  }

  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 612
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define mod 1000000007 //10^9+7
int main(void){
	int N,i,tate;
	scanf("%d",&N);
	char S1[60],S2[60];
	scanf("%s%s",S1,S2);
	int l = strlen(S1);
	long long ans=0;
	if(S1[0] == S2[0]){
		ans=3;
		i=1;
		tate=1;
	}
	else{
		ans=6;
		i=2;
		tate=0;
	}
	while(i<l){
		if(S1[i] == S2[i]){
			if(tate==1)	ans *= 2;
			else ans*=1;
			ans %= mod;
			i++;
			tate=1;
		}else{
			if(tate==1)ans *= 2;
			else ans *= 3;
			ans %= mod;
			i+=2;
			tate=0;
		}
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b-1);i>=(ll)(a);i--)

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

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

typedef long long ll;

using namespace std;
struct sieve{
  int p=0;
  vector<bool> furui;
  sieve(int n){
    furui.resize(n,1);
    furui[0]=0;
    furui[1]=0;
    for(int i=2;i<n;i++)if(furui[i])for(int j=i*2;j<n;j+=i)furui[j]=0;
  }
  bool isprime(int m){return furui[m];}
};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x;cin>>x;
  sieve si(10*x);
  repi(i,x,x*10){
    if(si.isprime(i)){
      cout<<i<<endl;
      return 0;
    }
  }


  return 0;

}


Measured memory_bytes: 384
N = int(input())
long_list = input().split()
count = 0
for i in range(N):
    long_i = int(long_list[i])
    for j in range(N-i-1):
        long_j = int(long_list[i+j+1])
        for k in range(N-i-j-2):
            long_k = int(long_list[i+j+k+2])
            if long_i == long_j or long_j == long_k or long_k == long_i:
                pass
            elif long_i + long_j > long_k and long_i + long_k > long_j and long_j + long_k > long_i:
                count += 1    
            else:
                pass

print("{0}".format(count))  


Measured memory_bytes: 9080
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

int main() {
  string s, t;
  cin >> s >> t;
  bool ans = false;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());

  if(s < t || (s.length() < t.length() && s == t)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef unsigned long long ull;
ull gcd(ull x, ull y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}
ull lcm(ull x, ull y) {
	return x / gcd(x, y) * y;
}
int n, a[111], b[111], vis[111]; ull x[111], y[111];
ull solve(int pos) {
	if (pos == -1) return 1;
	ull l = solve(a[pos]) * x[pos];
	ull r = solve(b[pos]) * y[pos];
	ull t = lcm(l, r);
	return t / x[pos] + t / y[pos];
}
int main() {
	while (cin >> n, n) {
		fill(vis, vis + n, 0);
		for (int i = 0; i < n; i++) {
			cin >> x[i] >> y[i] >> a[i] >> b[i]; a[i]--, b[i]--;
			if (a[i] != -1) vis[a[i]] = 1;
			if (b[i] != -1) vis[b[i]] = 1;
			ull r = gcd(x[i], y[i]);
			x[i] /= r, y[i] /= r;
		}
		int root = find(vis, vis + n, 0) - vis;
		cout << solve(root) << endl;
	}
}

Measured memory_bytes: 3020
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
#define INF 1000000000
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t)
{
    std::ostringstream os;
    os << t;
    return os.str();
}
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    ll s = 0;
    for (int i = 0; i < n - 1; i++)
    {
        s += v[i];
    }
    if (v[n - 1] < s)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-10
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 1e5+10;
const int N = 1e6+10;
const int E = 1e6+10;  
ll n,m,k;
int main(){
	cin>>n>>k;
	if(n%k==0){
		printf("0\n");
		return 0;
	}
	else {
		n%=k;
		ll ans = min(n,k-n);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdint>

int count[100000];

int main() {
	int n;
	std::cin >> n;

	int64_t ans = 1;
	for (int i = 0; i < n; ++i) {
		int64_t a;
		std::cin >> a;

		if ((a == 0 && count[a] != 0) || count[a] >= 2) {
			std::cout << 0 << std::endl;
			return 0;
		}

		if (a != 0 && count[a] == 0)
			ans = (ans * 2) % 1000000007;
		
		++count[a];
	}

	std::cout << ans << std::endl;
}

Measured memory_bytes: 640
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
    I LOVE CLARICE STARLING

     ♥LOVE♥        ♥LOVE♥
  ♥LOVE♥♥LOVE♥  ♥LOVE♥♥LOVE♥
♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
   ♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
      ♥LOVE♥♥LOVE♥♥LOVE♥
         ♥LOVE♥♥LOVE♥
            ♥LOVE♥
               ♥


    EXPLAINATION BELOW->
   

*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
void solve()
{
   string s;cin>>s;
   if(s=="ABC")cout<<"ARC\n";
   else cout<<"ABC\n";
}
int main()
{
   fastio
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


Measured memory_bytes: 3608
import sys
n = int(input())
ab = [list(map(int,input().split())) for _ in range(n)]
ab.sort(key = lambda x:x[1])
T = 0
lim = 0
for i in range(n):
  T += ab[i][0]
  lim = ab[i][1]
  if T > lim:
    print("No")
    sys.exit()
print("Yes")    
    

Measured memory_bytes: 53600
import Control.Applicative ((<$>))
import Control.Monad(unless)
import Data.ByteString.Char8(ByteString)
import qualified Data.ByteString.Char8 as B

import Control.Monad.State

main::IO ()
main = do
    [_, q] <- map read <$> words <$> getLine
    que <- Queue [] <$> map (f . B.words) <$> B.lines <$> B.getContents
    solve q que
    where f [n, t] = (n, readi B.readInt t)

solve :: Int -> Queue (ByteString, Int) -> IO ()
solve q que = evalStateT (rrs 0) que
  where rrs :: Int -> StateT (Queue (ByteString, Int)) IO ()
        rrs ct = do
          que <- get
          unless (isEmptyQue que) $ do
            let (Just((n, t), nque)) = deQue que
            if t > q then do
              put $ enQue (n, t - q) nque
              rrs(ct + q)
            else do
                lift $ putStrLn $ B.unpack n ++ " " ++ show (ct + t)
                put nque
                rrs(ct + t)

data Queue a = Queue [a][a] deriving Show

enQue :: a -> Queue a -> Queue a
enQue x (Queue xs ys) = Queue (x:xs) ys

deQue :: Queue a -> Maybe(a, Queue a)
deQue (Queue [][]) = Nothing
deQue (Queue xs (y:ys)) = Just (y, Queue xs ys)
deQue (Queue xs []) = deQue (Queue [] (reverse xs))

isEmptyQue :: Queue a -> Bool
isEmptyQue (Queue [][]) = True
isEmptyQue _ = False

readi :: Integral a => (ByteString -> Maybe(a, ByteString)) -> ByteString -> a
readi f s = let Just (n, _) = f s in n


Measured memory_bytes: 11860
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  if ((b-a) % 2 == 0) {
    cout << (b-a)/2 << endl;
    return 0;
  }
  if (n-b > a-1) {
    cout << a + (b-a-1)/2 << endl;
  } else {
    cout << n-b + 1 + (b-a-1)/2 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
//Author: Fuadul Hasan(fuadul202@gmail.com)
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int N   = 2e5 + 5;

int main(){
	
	int n;
	cin>>n;
	ll a,b;
	vector<pair<ll,ll>>v;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		v.push_back({b,a});
	}

	sort(v.begin(),v.end());
	ll sum = 0;
	bool f = false;
	for(int i = 0;i<n;i++){
		sum += v[i].second;
		if(sum > v[i].first){
			f = true;
		}
	}

	if(f){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;
	}


	

	return 0;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld PI = acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
//const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);

    int n; cin >> n;
    vi a(n);
    bool can = 1;
    rep(i,n) {
        cin >> a[i];
    }
    rep1(i,n-1) if(1 < a[i] - a[i-1]) can = 0;
    if(a[0]>0 || !can) {
        cout << -1 << '\n';
        return 0;
    }

    ll cnt = 0;
    for(int i = 1; i < n; ++i) {
        if(a[i-1]+1 == a[i]) cnt++;
        else cnt += a[i];
    }
    cout << cnt << '\n';
}

Measured memory_bytes: 1024
a, b, c, d = (int(i) for i in input().split())

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x%y)

def lcm(x, y):
    return x // gcd(x, y) * y

def ans(n, x, y):
    return n - n // c - n // d + n // lcm(x, y)

print(ans(b, c, d) - ans(a -1, c, d))

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

int main(){
  int n, a, b;
  int ans = 0;
  cin >> n >> a >> b;
  for(int i = 1; i <= n; i++){
    string x = to_string(i);
    int y = x.size();
    int sum = 0;
    for(int j = 0; j < y; j++){
      int c = x[j] - '0';
      sum += c;
    }
    if(a <= sum && sum <= b){ans += i;}
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define FB(i,a,b) for(ll i=a;i>=b;i--)
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define ND second
#define ST first
using namespace std;
const int N=1e5+5;
const ll M=1e9+7;

ll A[N];
ll H[N];

ll f_P(ll a,ll w);

int main()
{
	ll n;
	scanf("%lld",&n);
	F(i,1,n) scanf("%lld",&A[i]);

	H[0]=0;
	F(i,1,n) H[i]=(H[i-1]+f_P(i+1,M-2))%M;

	ll res=0;
	ll fact=1;
	F(i,1,n) res=(res+(((H[i-1]+H[n-i]+1)%M)*A[i])%M)%M, fact=(fact*i)%M;
	res=(res*fact)%M;
	printf("%lld\n",res);
}
///////
ll f_P(ll a,ll w)
{
	if(w==0) return 1;

	ll k=f_P(a,w/2);
	k=(k*k)%M;
	if(w%2==1) k=(k*a)%M;
	return k;
}



Measured memory_bytes: 1792
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
// const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i=0; i<n; ++i){
        cin >> h[i];
    }
    int ans = 0;
    for (int i=0; i<n; ++i){
        for (int j=0; j<=i; ++j){
            if(h[j] <= h[i]){
                if(j == i){
                    ans++;
                }
                continue;
            }
            else {
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define PI 3.14159265358979323846264338327950288419

using namespace std;

map<pair<string, string>, int> M1;

int n;
char str[39];

int main(){
	scanf("%d %s", &n, str);
	for(int i = 0; i < (1 << n); i++){
		string a = "";
		string b = "";
		for(int j = 0; j < n; j++){
			if(i & (1 << j)){
				a += str[j];
			}else{
				b += str[j];
			}
		}
		if(!M1.count({a, b})){
			M1[{a, b}] = 1;
		}else{
			M1[{a, b}]++;
		}
	}
	
	long long ans = 0;
	
	for(int i = 0; i < (1 << n); i++){
		string a = "";
		string b = "";
		for(int j = n - 1; j >= 0; j--){
			if(i & (1 << j)){
				a += str[j + n];
			}else{
				b += str[j + n];
			}
		}
		if(M1.count({a, b})){
			ans += M1[{a, b}];
		}
	}
	printf("%lld\n", ans);
	return 0;
}

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

using lint = long long;

int main() {
    int n;
    lint a, b;
    cin >> n >> a >> b;
    vector<lint> x(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }

    lint ans = 0;
    for (int i = 0; i < n - 1; i++) {
        ans += min(a * (x[i + 1] - x[i]), b);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
  int k,s;
  cin >> k >> s;
  int cnt = 0;
  for(int x = 0; x <= s && x <= k; x++){
    for(int y = 0; y <= s-x && y <= k; y++){
      int z = s - x - y;
      if(0 <= z && z <= k){
        // cout << "x: " << x << " y: " << y << " z: " << z << endl;
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

#define N 8
#define FREE 0
#define NOT_FREE 1

#define pos(i, j) (i+j)
#define neg(i, j) (i-j+N-1)

int dpos[2*N];
int dneg[2*N];
int row[N];
int col[N];

int input[N], k;

void init() {
  int i;
  for (i = 0; i < N; i++) {
    dpos[pos(i, i)] = FREE;
    dneg[neg(i, i)] = FREE;
    col[i] = FREE;
    input[i] = -1;
  }
}

void display() {
  int i, j, cnt;

  cnt = 0;
  for (i = 0; i < N; i++) {
    if (input[i] == row[i]){
      cnt++;
    }
  }
  if (cnt != k) {
    return;
  }
  
  for (i = 0; i < N; i++) {
    for (j = 0; j < N; j++) {
      if (row[i] == j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

void updateBoard(int i, int j, int status) {
  col[j] = status;
  dpos[pos(i, j)] = status;
  dneg[neg(i, j)] = status;
}

void putQueen(int i) {
  int j;
  
  if (i == N) {
    display();
    return;
  }

  for (j = 0; j < N; j++) {
    if (col[j] == NOT_FREE ||
	dpos[pos(i, j)] == NOT_FREE ||
	dneg[neg(i, j)] == NOT_FREE) {
      continue;
    }

    row[i] = j;
    updateBoard(i, j, NOT_FREE);

    putQueen(i + 1);
    
    updateBoard(i, j, FREE);
  }
}

int main() {
  int i;
  int r, c;

  init();

  scanf("%d", &k);
  for (i = 0; i < k; i++) {
    scanf("%d %d", &r, &c);
    input[r] = c;
  }

  putQueen(0);
  
  return 0;
}



Measured memory_bytes: 2112
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
          　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>

////多倍長整数, cpp_intで宣言
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
    char c;
    str = "";
    scanf("%c", &c);
    if (c == '\n')scanf("%c", &c);
    while (c != '\n' && c != -1 && c != ' ') {
        str += c;
        scanf("%c", &c);
    }
}

void scanc(char& str) {
    char c;
    scanf("%c", &c);
    if (c == -1)return;
    while (c == '\n') {
        scanf("%c", &c);
    }
    str = c;
}

double acot(double x) {
    return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

    ll a, v, b, w, t;
    scanf("%lld%lld%lld%lld%lld", &a, &v, &b, &w, &t);
    if (a > b)swap(a, b);
    printYN(a + v * t >= b + w * t);

    Please AC;
}


Measured memory_bytes: 3812
object Main extends App {
    val n = io.StdIn.readInt
    val k = io.StdIn.readInt
    val x = io.StdIn.readInt
    val y = io.StdIn.readInt
    val list = 1.to(n).toList
    val ret = list.map(i => if (i<=k) x else y).sum
    println(ret)
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    deque<int> deq;
    rep(i, N){
        if( i % 2 == N % 2) deq.push_back(A[i]);
        else deq.push_front(A[i]);
    }
    rep(i, N){
        cout << deq[i] << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 3840