akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int a[1000005],T,n;
bool check(int m,int k)
{
//	cout<<m<<' '<<k<<endl;
	if(k==0)	return false;
	if(m/k>1)	return true;
	return false;
}
int main()
{
//	scanf("%d",&T);
//	while(T--)
	{
		memset(a,0,sizeof(a));
		int maxn=0;
		bool flag=0;
		scanf("%d",&n);
		for(int i=1;i<=n;i++)
		{
			int x;
			scanf("%d",&x);
			maxn=max(maxn,x),a[x]++;
			if(x!=maxn&&x!=maxn-1)	flag=1;
		}
		if(flag)	{printf("No\n");return 0;}
		if(n==1&&a[0]!=1)	{printf("No\n");return 0;}
		if((a[maxn]==n&&maxn==n-1)||(a[maxn]==n&&maxn==1))	{printf("Yes\n");return 0;}
		if(check(n-a[maxn-1],maxn-a[maxn-1]))	{printf("Yes\n");return 0;}
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  pair <long long, long long> vect[n];
  for (int i = 0; i < n; i++){
    cin >> vect[i].first >> vect[i].second;
  }
  long long money = 0;
  long long index = 0;
  sort(vect, vect + n);
  while (m > 0){
    if (vect[index].second <= m){
      money += vect[index].first * vect[index].second;
      m -= vect[index].second;
    }
    else {
      money += vect[index].first * m;
      break;
    }
    index++;
  }
  cout << money << endl;
  return 0;
}


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

using namespace std;

using ll = long long;

template<class T>
struct Graph {
    const T INF, n;
    int src;
    bool is_neg_cycle;
    std::vector<std::vector<std::pair<int, T>>> adj;
    std::vector<T> d;
 
    Graph(int _n, int _s)
        : INF(std::numeric_limits<T>::max()), n(_n), src(_s),
          is_neg_cycle(false), adj(n), d(n, INF) { }
 
    void add_edge(int u, int v, T w) { adj[u].emplace_back(make_pair(v, w)); }
    T ShortestDistance(const int t) const { return d[t]; }
    bool IsNegativeCycleFromS() const { return is_neg_cycle; }
 
    bool CheckNegativeCycle() {
        std::fill(d.begin(), d.end(), 0);
        BellmanFord();
        return is_neg_cycle;
    }
 
    void BellmanFord() {
        d[src] = 0;
        for (int i = 0; ; ++i) {
            bool update = false;
            for (int v = 0; v < n; ++v)
                for (const auto &e : adj[v])
                    if (d[v] < INF && d[v] + e.second < d[e.first]) {
                        d[e.first] = d[v] + e.second;
                        update = true;
                        if (e.first == n - 1 && n <= i) is_neg_cycle = true;
                    }
            if (!update) break;
            if (i == 2 * n) { break; }
        }
    }
};

// template<class T>
// struct Graph {
//     const int n, src;
//     const T INF;
//     bool is_neg_cycle;
//     std::vector<std::vector<std::pair<int, T>>> adj;
//     std::vector<T> d;

//     Graph(int _n, int _s)
//         : n(_n), src(_s), INF(std::numeric_limits<T>::max()),
//           is_neg_cycle(false), adj(n), d(n, INF) { }

//     void add_edge(int u, int v, T w) { adj[u].push_back(std::make_pair(v, w)); }
//     T ShortestDistance(const int t) const { return d[t]; }
//     bool IsNegativeCycleFromS() const { return is_neg_cycle; }
//     void ChangeSource(int _s) { src = _s; fill(d.begin(), d.end(), INF); }

//     void BellmanFord() {
//         d[src] = 0;
//         for (int i = 0; ; ++i) {
//             bool update = false;
//             for (int v = 0; v < n; ++v)
//                 for (const auto &e : adj[v])
//                     if (d[v] < INF && d[v] + e.second < d[e.first]) {
//                         d[e.first] = d[v] + e.second;
//                         update = true;
//                     }
//             if (!update) break;
//             if (i == n - 1) { is_neg_cycle = true; break; }
//         }
//     }
// };

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

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

    Graph<ll> g(n, 0);
    for (int i = 0; i < m; ++i) {
        ll a, b, c;
        cin >> a >> b >> c;
        g.add_edge(a - 1, b - 1, -c);
    }

    g.BellmanFord();
    if (g.is_neg_cycle) cout << "inf\n";
    else cout << -g.ShortestDistance(n - 1) << endl;

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<vector>
#include<list>
#include<map>
#include<unordered_map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

#define ld  long double
#define ll  long long int
#define ull unsigned long long int
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,s,n) for(int i=s;i<n;i++)
#define endl "\n"

const ll INF = 1LL << 60;
const ld EPS = 1e-11;

//切り上げ整数除算
int divRoundUp(const int& a, const int& b) { return (a + b - 1) / b; }
//四捨五入
int roundOff(const double& a) { return (int)(a + 0.5); }
// r の(誤差付きの)符号に従って, -1, 0, 1 を返す.
int sgn(const ld& r) { return (r > EPS) - (r < -EPS); }
// a, b の(誤差付きの)大小比較の結果に従って, -1, 0, 1 を返す.
int sgn(const ld& a, const ld& b) { return sgn(a - b); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;

inline void Main() {
	string day_of_week[7] = { "SUN","MON","TUE","WED","THU","FRI","SAT" };
	string s; cin >> s;
	for (int i = 0; i < 7; ++i) {
		if (s != day_of_week[i])continue;
		cout << 7 - i << endl;
	}
}

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

	Main();

	return 0;
}

Measured memory_bytes: 256
n = input()
h = input().split(' ')

terminal_flg = False
max_step_num = 0

step_num = 0
current_step = 0
ori_step_num = 0
while current_step < len(h) -1:
  if int(h[current_step]) < int(h[current_step+1]):
    if max_step_num < step_num:
      max_step_num = step_num
    step_num = 0
    if len(h) - current_step -1 < max_step_num:
      break
  else:
    step_num +=1
  current_step += 1
else:
  if max_step_num < step_num:
      max_step_num = step_num

    
print(max_step_num)

Measured memory_bytes: 11132
'use strict'

function main(input) {
  input = input.trim().split('\n')
  const n = Number(input[0])
  const trooper = input[1].split('')

  const countW = [0]
  for (let i = 0; i < n; i++) {
    if (trooper[i] === 'W') countW.push(countW[i] + 1)
    else countW.push(countW[i])
  }
  // countW.shift()

  let min = Number.MAX_SAFE_INTEGER
  for (let i = 0; i < n; i++) {
    let tmp = 0

    // WからEになる人
    tmp += countW[i]

    // console.log(countW[i])
    // EからWになる人
    tmp += n - (i + 1) - countW[n] + countW[i + 1]
    // console.log(n - countW[n] - countW[i])

    min = Math.min(tmp, min)
  }

  console.log(min)
  // console.log(trooper)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))



Measured memory_bytes: 18452
n, k = map(int, input().split())
point = []
xarray = []
yarray = []
for _ in range(n):
    x, y = map(int, input().split())
    point.append([x, y])
    xarray.append(x)
    yarray.append(y)

xarray.sort()
yarray.sort()

ans = 4*(10**18)+10
for xi in range(n):
    for xj in range(xi+1, n):
        for yi in range(n):
            for yj in range(yi+1, n):
                lx, rx = xarray[xi], xarray[xj]
                by, ay = yarray[yi], yarray[yj]
                num = 0
                for i in range(n):
                    x, y = point[i]
                    if lx <= x <= rx and by <= y <= ay:
                        num += 1
                if num >= k:
                    ans = min(ans, (rx-lx)*(ay-by))
print(ans)

Measured memory_bytes: 50916
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(0);
    
    int N, K;
    cin >> N >> K;
    vector<int> V(N);
    rep(i, N) cin >> V[i];

    int ans = 0;
    vector<int> neg;
    for (int a = 0; a <= N; ++a) {
        for (int b = 0; a+b <= N && a+b <= K; ++b) {
            neg.clear();
            int tmp = 0;
            rep(i, a) {
                tmp += V[i];
                if (V[i] < 0) {
                    neg.push_back(V[i]);
                }
            }
            rep(i, b) {
                tmp += V[N-i-1];
                if (V[N-i-1] < 0) {
                    neg.push_back(V[N-i-1]);
                }
            }
            if (!neg.empty() && a+b < K) {
                sort(neg.begin(), neg.end());
                rep(i, min((int) neg.size(), K-a-b)) {
                    tmp -= neg[i];
                }
            }
            ans = max(ans, tmp);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    string s;
    cin >> s;
    replace(s.begin(), s.end(), ',', ' ');
    cout << s;
    return 0;
}

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


void solve(long long N, std::vector<long long> A){
    map<long long, long long> cnts;
    for(auto a:A){
        cnts[a-1]++;
        cnts[a]++;
        cnts[a+1]++;
    }
    auto ans=LONG_LONG_MIN;
    for(auto &kv:cnts){
        if(kv.second > ans)ans=kv.second;
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 6912
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using _TYPE = int;
typedef tree< _TYPE, null_type, less< _TYPE >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

int h, w;
int dp[1003][1003];
char inp[1003][1003];
const int mod = (int) 1e9 + 7;

int solve(int i, int j) {
    if(i >= h || j >= w || inp[i][j] == '#')
        return 0;
    if(i == h - 1 && j == w - 1)
        return 1;
    int &rt = dp[i][j];
    if(rt != -1)
        return rt;
    rt = 0;
    rt += solve(i + 1, j);
    if(rt >= mod)
        rt -= mod;
    rt += solve(i, j + 1);
    if(rt >= mod)
        rt -= mod;
    return rt;
}

int main() {
    IO;
    cin >> h >> w;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++)
            cin >> inp[i][j];
    }
    memset(dp, -1, sizeof dp);
    cout << solve(0, 0);
    return 0;
}


Measured memory_bytes: 5248
#include <iostream>
#include <fstream>
#define nmax 101

using namespace std;
ifstream fin("p.in");
ofstream fout("p.out");

int main()
{
    int n,k;
    int v[nmax];
    cin>>n>>k;
    for(int i=1; i<=n; i++)
        cin>>v[i];

    bool dp[nmax*nmax*10]={0}; ///TRUE IF FIRST WINS WITH i STONES REMAINING

    for(int st=0; st<=k; st++)
        for(int i=1; i<=n; i++)
            if(st>=v[i] && dp[st-v[i]]==0)
                dp[st]=1;

    if(!dp[k]) cout<<"Second";
    else cout<<"First";
    return 0;
}


Measured memory_bytes: 384
using System;

namespace B___Digital_Gifts
{
    class Program
    {
        static void Main(string[] args)
        {
            var n=int.Parse(Console.ReadLine());
            var ans = 0.0;
            for(var i=0; i<n; i++)
            {
                var a=Console.ReadLine().Split(' ');
                if(a[1]=="JPY")
                {
                    ans +=double.Parse(a[0]);
                }
                else
                {
                    ans += double.Parse(a[0]) * 380000.0;
                }
            }
            Console.WriteLine(ans);
        }
    }
}

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

#define rep(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define SZ(x) ((int) (x).size())
typedef long long ll;

const int MOD = (int)1e9 + 7;
int main() {
    long long n, m;
    while(cin >> n >> m) {
        if(2*n >= m)  cout << m / 2 << endl;
        else cout << (m - 2*n) / 4 + n << endl;
    }
    return 0;
}


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

typedef long long ll ; 
typedef unsigned long long ull ; 
typedef vector<int> vi ; 
typedef vector<vi> vii ;
typedef vector<ll> vl ;
typedef vector<vl> vll ;
typedef set<int> si ; 
typedef map<int,int> mii ; 
typedef map<ll,ll>  mll ; 
typedef map<string,int> msi ;
typedef set<ll> sl ; 
typedef set<char> sc ; 
typedef pair<int,int> pii ;


#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
const int INF = 1 << 29 ; 
#define MOD (ll)(1e9+7)
#define eps 1e-6
#define pb push_back 
#define mp make_pair 
#define DEBUG(x)		cout << '>' << #x << ':' << x << endl;
#define F first 
#define S second 

int main() 
{
	ios::sync_with_stdio(0) ;
	

	int n;
	cin >> n;
	int a[n][3];
	REP(i,n) {
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	}	
	int dp[n+5][3];
	dp[0][0] = 0;
	dp[0][1] = 0;
	dp[0][2] = 0;
	dp[1][0] = a[0][0];
	dp[1][1] = a[0][1];
	dp[1][2] = a[0][2];
	for(int i = 2; i<= n; ++i) {
		dp[i][0] = a[i-1][0] + max(dp[i-1][1] , dp[i-1][2]);
		dp[i][1] = a[i-1][1] + max(dp[i-1][0] , dp[i-1][2]);
		dp[i][2] = a[i-1][2] + max(dp[i-1][0] , dp[i-1][1]);
	}
	cout << max(dp[n][0] , max(dp[n][1] , dp[n][2])) << endl;
	return 0 ; 
}


Measured memory_bytes: 2560
#include<iostream>
#include<string>
using namespace std;
int main()
{

int i,j,c=0;
string s,s1;
    cin>>s;
    cin>>s1;
for(i=0,j=0;i<s.size(),j<s1.size();i++,j++)
    {
    
    
    if(s[i]!=s1[j])
{
c++;
}
}
    

cout<<c<<endl;





return 0;
}

Measured memory_bytes: 3484
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod 			1000000007
#define tc(t) 			int t;cin >> t;while(t--)
#define for0(i , n)		for(int i=0;i<n;i++)
#define loop(i , a, b)	for(int i=a;i<=b;i++)
#define endl 			'\n'
#define inf 			1e18
#define fi 				first
#define se 				second

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

int n;
int a[3001];
int dp[3001][3001][2];

int solve(int i, int j, int fl) {
	if (i > j) return 0;
	if (dp[i][j][fl] != -1) return dp[i][j][fl];
	if (fl) {
		return dp[i][j][fl] = max(a[i] + solve(i + 1, j, 0), a[j] + solve(i, j - 1, 0));
	}

	return dp[i][j][fl] = min(solve(i + 1, j, 1), solve(i, j - 1, 1));
}

signed main() {

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

#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r" , stdin);
	freopen("output.txt" , "w" , stdout);
#endif

	cin >> n;
	int sum = 0;
	for0(i, n) cin >> a[i], sum += a[i];

	memset(dp, -1, sizeof(dp));

	int x = solve(0, n - 1, 1);
	int y = sum - x;

	cout << x - y << endl;

	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);

  for(int i = 0; i < N; i++) cin >> vec.at(i);

  int ans = 0;
  int now = 0;
  int height = vec.at(0);

  for(int i = 1; i < N; i++){
    if(height >= vec.at(i)){
      now += 1;
      height = vec.at(i);
    } else {
      height = vec.at(i);
      if(now >= ans){
        ans = now;
      }
      now = 0;
    }

  }

  if(now >= ans){
    ans = now;
  }
  
  cout << ans << endl;

}




Measured memory_bytes: 640
from collections import Counter
N, *A = map(int, open(0).read().split())
A.sort(reverse=True)
C = Counter(A)
ans = 0
for a in A:
    if C[a] == 0:
        continue
    C[a] -= 1
    partner = (1 << (a.bit_length())) - a
    if C[partner] > 0:
        ans += 1
        C[partner] -= 1
print(ans)

Measured memory_bytes: 33712
//
// Created by 永徳泰明 on 2019-01-13.
//

#include <bits/stdc++.h>

typedef long long ll;

using namespace std;
#define dump(x)  cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define fill(x, y) memset(x,y,sizeof(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 999999999;
typedef pair<int, int> p;

void readFromInputFile() {
#ifdef LOCAL
    static std::ifstream in("/Users/hoo/CLionProjects/for_atcoder/input");
    std::cin.rdbuf(in.rdbuf());
#endif
}

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

    vector<int> a, b, df;
    rep(i, N) {
        int t;
        cin >> t;
        a.push_back(t);
    }
    rep(i, N) {
        int t;
        cin >> t;
        b.push_back(t);
    }

    int c = 0;
    ll sum = 0;
    rep(i, N) {
        if (b[i] - a[i] > 0) {
            sum += (b[i] - a[i]);
            c++;
        } else {
            df.push_back(a[i] - b[i]);
        }
    }
    sort(df.begin(), df.end(), greater<>());
//    rep(i, df.size()){
//        cout<<df[i]<<endl;
//    }

    int i = 0;
    for (; i < df.size() && sum > 0; i++) {
        sum -= df[i];
    }
    if (sum > 0) {
        cout << -1 << endl;
    } else {
        cout << i + c << endl;
    }


    return 0;
}


Measured memory_bytes: 1784
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
int main(){
	ll n,k;
	cin>>n>>k;
	vector<ll> h(n),dp(n);
	for(ll i=0;i<n;i++){
		cin>>h[i];
	}
	
	dp[0] = 0;
	for(ll i=1;i<k;i++){
		dp[i] = abs(h[0]-h[i]);
	}
	
	for(ll i=k;i<n;i++){
		ll lmin = INT_MAX;
		for(ll j=1;j<=k;j++){
			ll var = abs(h[i-j]-h[i])+dp[i-j];
			if(var<lmin){
				lmin = var;
			}
			
		}
		dp[i] = lmin;
		
	}
	cout<<dp[n-1]<<"\n";
	
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    int num[4];
    num[3]=n%10;
    n=(n-num[3])/10;
    num[2]=n%10;
    n=(n-num[2])/10;
    num[1]=n%10;
    num[0]=(n-num[1])/10;
    if (num[0]+num[1]+num[2]+num[3]==7)
    {
        cout<<num[0]<<"+"<<num[1]<<"+"<<num[2]<<"+"<<num[3]<<"=7";
        return 0;
    }
    else if (num[0]+num[1]+num[2]-num[3]==7)
    {
        cout<<num[0]<<"+"<<num[1]<<"+"<<num[2]<<"-"<<num[3]<<"=7";
        return 0;
    }
    else if (num[0]+num[1]-num[2]+num[3]==7)
    {
        cout<<num[0]<<"+"<<num[1]<<"-"<<num[2]<<"+"<<num[3]<<"=7";
        return 0;
    }
    else if (num[0]+num[1]-num[2]-num[3]==7)
    {
        cout<<num[0]<<"+"<<num[1]<<"-"<<num[2]<<"-"<<num[3]<<"=7";
        return 0;
    }
    else if (num[0]-num[1]+num[2]+num[3]==7)
    {
        cout<<num[0]<<"-"<<num[1]<<"+"<<num[2]<<"+"<<num[3]<<"=7";
        return 0;
    }
    else if (num[0]-num[1]+num[2]-num[3]==7)
    {
        cout<<num[0]<<"-"<<num[1]<<"+"<<num[2]<<"-"<<num[3]<<"=7";
        return 0;
    }
    else if (num[0]-num[1]-num[2]+num[3]==7)
    {
        cout<<num[0]<<"-"<<num[1]<<"-"<<num[2]<<"+"<<num[3]<<"=7";
        return 0;
    }
    else if (num[0]-num[1]-num[2]-num[3]==7)
    {
        cout<<num[0]<<"+"<<num[1]<<"+"<<num[2]<<"+"<<num[3]<<"=7";
        return 0;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int t[(1<<18)];
 
void Set(int a,int b,int x,int k=0,int l=0,int r=(1<<17)){
  if(b<=l || r<=a)return;
  if(a<=l && r<=b){
    t[k]=max(t[k],x);
    return;
  }
  int m=(l+r)/2;
  Set(a,b,x,k*2+1,l,m);
  Set(a,b,x,k*2+2,m,r);
}
 
int Get(int i){
  i+=(1<<17)-1;
  int res=t[i];
  while(i){
    i=(i-1)/2;
    res=max(res,t[i]);
  }
  return res;
}
          
int n,q;
int value[100005];
 
int main(){
  value[0]=2147483647;
   
  scanf("%d %d",&n,&q);
  for(int i=1;i<=q;i++){
    int type;
    scanf("%d",&type);
    if(type==0){
      int l,r;
      scanf("%d %d %d",&l,&r,&value[i]);
      r++;
      Set(l,r,i);
    }else{
      int target;
      scanf("%d",&target);
      int ans=Get(target);
      printf("%d\n",value[ans]);
    }
  }
  return 0;
}

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


int main() {
  long long X, K, D;
  cin >> X >> K >> D;
  X = abs(X);
  long long M = X/D;
  if(M >= K){
    cout << abs(X-K*D) << endl;
    return 0;
  }
  K -= M;
  if(K%2==0) cout << abs(X-M*D) << endl;
  else cout << abs(X-(M+1)*D) << endl;
}


Measured memory_bytes: 3644
def swap(A,i,j):
    A[i],A[j] = A[j],A[i]
    return A

def isStable(A):
    for i in range(1, len(A)):
        if A[i][1] == A[i-1][1]:
            if A[i][2] < A[i-1][2]:
                return False
    return True

def partition(A,p=0, r=None):
    if r is None:
        r = len(A)-1
    x = A[r]
    i = p-1
    for j in range(p,r):
        if A[j][1] <= x[1]:
            i += 1
            swap(A,i,j)
    swap(A,i+1,r)
    return i+1

def quick(A,p=0,r=None):
    if r is None:
        r = len(A)-1
    if p < r:
        q = partition(A,p,r)
        quick(A,p,q-1)
        quick(A,q+1,r)

import sys
if __name__ == "__main__":
    n = int(sys.stdin.readline())
    A = []
    for i in range(n):
        card = sys.stdin.readline().split()
        A.append([card[0], int(card[1]), i])
    quick(A,0,n-1)
    if isStable(A):
        print("Stable")
    else:
        print("Not stable")
    for card in A:
        print(card[0], card[1])

Measured memory_bytes: 24720
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define INF 1000000000000000LL
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
//#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl

signed main(){
	IO_STREAM;
	long double A,B;
	cin>>A>>B;
	cout<<(ll)(A*B)<<endl;
	return 0;
}


Measured memory_bytes: 3748
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
#define ALL(a) a.begin(), a.end()
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
typedef vector<ll> vec;
typedef vector<vec> mat;

vector<pair<int,pair<int,int>>> pmd;
vector<pair<int,int>> lmt;

int main(){
    int n;
    cin >> n;
    rep(i,n){
        int x,y,h;
        cin >> x>> y>> h;
        if(h!=0){
            pmd.push_back(mp(h,mp(x,y)));
        }else{
            lmt.push_back(mp(x,y));
        }
    }
    rep(i,101){
        rep(j,101){
            int x=i;
            int y=j;
            bool ok=1;
            ll hight=pmd[0].fi+abs(pmd[0].se.fi-x)+abs(pmd[0].se.se-y);
            rep(k,pmd.size()){

                ll temp=pmd[k].fi+abs(pmd[k].se.fi-x)+abs(pmd[k].se.se-y);
                if(temp!=hight)ok=0;
            }
            rep(k,lmt.size()){
                ll temp=abs(lmt[k].fi-x)+abs(lmt[k].se-y);
                if(temp<hight)ok=0;
            }
            if(ok){
                cout<<x<<' '<<y<<' '<<hight<<endl;
                return 0;
            }
        }
    }
    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 3620
H, W = map( int, input().split())

a = []
b = []
c = []

for i in range(H):
  a1 = input()
  if('#' in a1):
     a.append(a1)
        
  else:
      continue

a = list(zip(*a))
l1 = len(a)
         
for j in range(l1):
  b1 = a[j]
   
  if( '#' in b1):
      b.append(b1)
  
  else:
      continue
         
c = list(zip(*b))
l2 = len(c)

for n in range(l2):
         print("".join(c[n]))

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

int main(){
  int n;
  string s;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> s;
    if(s == "Y"){
      cout << "Four" << endl;
      break;
    }
    else if(i == n - 1 && s != "Y"){
      cout << "Three" << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m,i,j,a[2020];
long long c,r;
int main() {
  scanf("%d%d",&n,&m);
  for (i=0; i<n; i++) {
    scanf("%d",&a[i]);
    r+=a[i];
  }
  for (j=1; j<n; j++) if (1LL*m*j<r) {
    multiset<int> s;
    for (i=1; i<=j; i++) s.insert(a[n-i]);
    for (c=i=0; i<n; i++) {
      s.insert(a[i]);
      c+=*s.begin();
      s.erase(s.find(a[(n+i-j)%n]));
    }
    r=min(r,c+1LL*m*j);
  }
  printf("%lld\n",r);
  return 0;
}


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

#define MOD (1000000007)
const int N=5e5+10;
int h[N], l[N], r[N];
vector<int> L[N];
int x[N], v[N], a[N];
bool cmp(const int &a, const int &b) { return v[a]<v[b]; }
int f[N], S[N];

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int n, m;
    cin>>n;
    for(int i=1; i<=n; i++) cin>>x[i]>>v[i], a[i]=i;
    sort(a+1, a+1+n, cmp);
    int stk[N], p[N], t=0;
    for(int i=1; i<=n; i++) {
        if(!t || stk[t]<x[a[i]]) stk[++t]=x[a[i]], p[t]=i;
        int lo=1, hi=t, mid;
        while(lo<hi) {
            mid=(lo+hi)>>1;
            if(stk[mid]<x[a[i]]) lo=mid+1;
            else hi=mid;
        }
        l[i]=p[hi];
    }
    t=0;
    for(int i=n; i>=1; i--) {
        if(!t || stk[t]>x[a[i]]) stk[++t]=x[a[i]], p[t]=i;
        int lo=1, hi=t, mid;
        while(lo<hi) {
            mid=(lo+hi)>>1;  
            if(stk[mid]>x[a[i]]) lo=mid+1;
            else hi=mid;
        }
        r[i]=p[hi];
    }

    for(int i=1; i<=n; i++) L[r[i]].push_back(l[i]);
    f[0]=S[0]=1;
    for(int i=1; i<=n; i++) {
        S[i]=S[i-1];
        sort(L[i].begin(), L[i].end());
        for(int j:L[i]) {
            f[i]=(1ll*f[i]+S[i]-(j-2>=0?S[j-2]:0)+MOD)%MOD;
            S[i]=(f[i]+S[i-1])%MOD;
        }
    }
    cout<<f[n]<<endl;
    return 0;
}

Measured memory_bytes: 32640
//#include "stdio.h"
//
//int N;
//int flag[100000] = {};
//int ans;
//
//int main() {
//	
//	scanf("%d", &N);
//	while (N != 0) {
//		ans = 0;
//		for (int i = 0; i < N; i++) {
//			scanf("%d", &flag[i]);
//			if (i % 2 == 1) {
//				for (int j = i - 1; j >= 0; j--) {
//					if (flag[j] == flag[i])break;
//					flag[j] = flag[i];
//				}
//			}
//		}
//		for (int i = 0; i < N; i++) {
//			if (flag[i] == 0)ans++;
//		}
//		printf("%d\n", ans);
//		scanf("%d", &N);
//	}
//
//	return 0;
//}

#include"stdio.h"

int N;
int x[3000];
int xbox[3000];
int y[3000];
int ybox[3000];
int place[3000];
int ans = 0;
int box[3000];
int cal;
bool flag[5001][5001] = {};

void MergeSort(int  n[], int left, int right) {
	if (left == right)return;
	int mid = (left + right) / 2;
	MergeSort(n, left, mid);
	MergeSort(n, mid + 1, right);
	for (int i = left; i <= mid; i++) {
		box[i] = n[i];
		xbox[i] = x[i];
		ybox[i] = y[i];
	}
	for (int i = mid + 1, j = right; i <= right; i++, j--) {
		box[i] = n[j];
		xbox[i] = x[j];
		ybox[i] = y[j];
	}
	int a = left, b = right;
	for (int i = left; i <= right; i++) {
		if (box[a] < box[b]) {
			x[i] = xbox[a];
			y[i] = ybox[a];
			n[i] = box[a++];
		}
		else {
			x[i] = xbox[b];
			y[i] = ybox[b];
			n[i] = box[b--];
		}
	}
}

int main() {
	scanf("%d", &N);
	while (N != 0) {
		ans = 0;
		for (int i = 0; i < N; i++) {
			scanf("%d %d", &x[i], &y[i]);
			flag[x[i]][y[i]] = true;
			place[i] = x[i] * 5001.0 + y[i];
		}
		MergeSort(place, 0, N - 1);
		for (int i = 0; i < N; i++) {
			for (int j = i + 1; j < N; j++) {
				if (x[j] + y[j] - y[i] >= 0 && x[j] + y[j] - y[i] <= 5000 && y[j] - x[j] + x[i] >= 0 && y[j] - x[j] + x[i] <= 5000 && x[i] + y[j] - y[i] >= 0 && x[i] + y[j] - y[i] <= 5000 && y[i] - x[j] + x[i] >= 0 && y[i] - x[j] + x[i] <= 5000) {
					if (flag[x[j] + y[j] - y[i]][y[j] - x[j] + x[i]] && flag[x[i] + y[j] - y[i]][y[i] - x[j] + x[i]]) {
						//	printf("%d %d  %d %d  %d %d  %d %d\n", x[i], y[i], x[j], y[j], x[j] + y[j] - y[i], y[j] - x[j] + x[i], x[i] + y[j] - y[i], y[i] - x[j] + x[i]);
						//	printf("%d\n", (x[j] - x[i]) * (x[j] - x[i]) + (y[j] - y[i]) * (y[j] - y[i]));
						if (ans < (x[j] - x[i]) * (x[j] - x[i]) + (y[j] - y[i]) * (y[j] - y[i])) ans = (x[j] - x[i]) * (x[j] - x[i]) + (y[j] - y[i]) * (y[j] - y[i]);
					}
				}
			}
		}
		printf("%d\n", ans);
		scanf("%d", &N);
	}
	return 0;
}

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

int main(){
  long n,i,j,cur=0;
  cin >> n;
  vector<pair<long, long>> a(n);
  for(i=0; i<n; i++){
    cin >> a[i].first;
    a[i].second=i;
  }
  sort(a.begin(),a.end());
  j=a[n-1].second;
  for(i=0; i<n; i++){
    if(i!=j){
      cout << a[n-1].first << endl;
    }else{
      cout << a[n-2].first << endl;
    }
  }
}

Measured memory_bytes: 4736
#include<stdio.h>
#include<stdlib.h>

int main()
{
	int H, W;
	
	while(scanf("%d %d", &H, &W))
	{
		if(H == 0 && W ==0)
		{
			break;
		}
		
		for(int i = 0;i < W; i++)
		{
			printf("#");
		}
		printf("\n");
		
		for(int i = 0;i < H - 2; i++)
		{
		printf("#");
			for(int j = 0;j < W - 2; j++)
			{			
				printf(".");				
			}
		printf("#");
		printf("\n");
		}
		
		for(int i = 0;i < W; i++)
		{
			printf("#");
		}
		printf("\n");		
		printf("\n");
	}
	return 0;
}


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

int main(){
	int n;
	cin>>n;
vector<vector<int> > dp(3,vector<int>(101,0));

vector<vector<int> > a(n,vector<int>(3,0));
for(int i=0;i<n;i++){
	for(int j=0;j<3;j++){
	cin>>a[i][j];
	dp[j][a[i][j]]++;
	}
}
for(int i=0;i<n;i++){
	int ans =0;
	for(int j=0;j<3;j++){
	if(dp[j][a[i][j]]==1)ans+=a[i][j];
	}
	cout<<ans<<endl;
}

return 0;
}



Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int m,n;
	cin>>m>>n;
	if(m<n)
		swap(m,n);
	m=m/n;
	if(m>=2)
		cout<<":("<<endl;
	else
        cout<<"Yay!"<<endl;
	return 0;
}


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

using namespace std;

const int inf = 1e9 + 7;
const int N = 1e6 + 5;

int n, k;
long long ans;

int main(){
      scanf("%d %d", &n, &k);

      for(int b = k + 1; b <= n; b ++){
            if(k == 0)
                  ans += max(0, b - k - 1);
            else
                  ans += b - k;
            for(int a = b; a <= n; a += b){
                  int l = a + k, r = a + b - 1;
                  r = min(n, r);
                  ans += max(r - l + 1, 0);
            }
      }

      printf("%lld\n", ans);
}


Measured memory_bytes: 256
A,B,C,D,E,F=map(int,input().split())
w=set()
s=set()
for i in range(31):
    for j in range(16):
        if 100*(A*i+B*j)<=F:
            w.add(100*(A*i+B*j))
for i in range(1501):
    for j in range(751):
        if C*i+D*j<=F/2:
            s.add(C*i+D*j)
w=list(w)
w.sort()
del w[0]
s=list(s)
s.sort()
M=-1
for i in w:
    for j in range(len(s)-1,-1,-1):
        if s[j]*100<=E*i:
            if s[j]>M*i and i+s[j]<=F:
                W,S=i,s[j]
                M=s[j]/i
print(W+S,S)

Measured memory_bytes: 40940
import sys


fin = sys.stdin.readline
N = int(fin())
a_list = [int(elem) for elem in fin().split()]
is_ball_in = [False] * N
for i in reversed(range(1, N + 1)):
    num_balls = 0
    for j in range(i, N + 1, i):
        num_balls += is_ball_in[j - 1]
    num_balls %= 2
    a = a_list[i - 1]
    if num_balls != a:
        is_ball_in[i - 1] = True
    else:
        is_ball_in[i - 1] = False

num_boxes_with_a_ball = sum(is_ball_in)
print(num_boxes_with_a_ball)
indices = [i for i, b in enumerate(is_ball_in, start=1) if b]
print(*indices)


Measured memory_bytes: 71416
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(int argc, char **argv) {
	int n, m, k;
	cin >> n >> m >> k;
	REP(i, n + 1) REP(j, m + 1) {
		if (m * i + j * (n - i) - j * i == k) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(a) begin(a), end(a)
#define csz(a) (int) a.size()
#define pb push_back
#define epb emplace_back
#define mp make_pair
#define load(a, v) fill(begin(a), end(a), v)
#define load_mem(a, v) memset(a, v, sizeof(a));
#define iostream_optimize() ios::sync_with_stdio(false); cin.tie(0);
#define long long long
const long MOD = 1e9+7, LINF = 1e18 + 1e16;
const int INF = 1e9+1;
const double EPS = 1e-10;
const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};
const long P1 = 31, P2 = 37, M1 = 1e9+7, M2 = 1e9+9;
 
/* <<<<<<<<<<<<<<<<<<<<<<<<<<<< END TEMPLATE >>>>>>>>>>>>>>>>>>>>>>>>>>> */
const int N = 1e5+1;

int n;
long C, x[N], v[N], pref[N], suff[N], mxsuff[N], mxsuffx[N];
long ans;
int main() {
	iostream_optimize();
	cin >> n >> C;
	for(int i = 0; i < n; i++) cin >> x[i] >> v[i];
	for(int i = 0; i < n; i++) {
		pref[i] = (i ? pref[i-1] : 0) + v[i];
	}
	for(int i = n-1; i >= 0; i--) {
		suff[i] = (i < n-1 ? suff[i+1] : 0) + v[i];
		mxsuff[i] = max((i < n-1 ? mxsuff[i+1] : 0), suff[i] - (C - x[i]));
		mxsuffx[i] = max((i < n-1 ? mxsuffx[i+1] : 0), suff[i] - 2ll * (C - x[i]));
	}
	for(int i = 0; i < n; i++) {
		ans = max(pref[i] - 2*x[i] + (i < n-1 ? mxsuff[i+1] : 0), ans);
		ans = max(pref[i] - x[i] + (i < n-1 ? mxsuffx[i+1] : 0), ans);
	}
	for(int i = 0; i < n; i++) ans = max(suff[i] - (C - x[i]), ans);
	cout << ans;
}


Measured memory_bytes: 4992
from collections import deque
from collections import defaultdict
import sys

H,W=map(int,input().split())
maze=[[0]*W for _ in range(H)]
b=0                  # ブロックの数
for i in range(H):
  a=str(input())
  for j in range(W):
    if a[j]=='#':
      b+=1
    maze[i][j]=a[j]
def BFS(maze,s,g):
  que=deque()
  sy,sx=s[0],s[1]
  gy,gx=g[0],g[1]
  que.append([sx,sy])
  dist=[[0]*W for _ in range(H)]
  seen=[]
  seen.append([sx,sy])   
  Next=[[-1,0],[1,0],[0,1],[0,-1]]
  while len(que)!=0:
    l=que.popleft()
    for n in Next:
      x,y=l[0]+n[0],l[1]+n[1]
      if (x<0 or x>=W or y<0 or y>=H) or maze[y][x]=='#':
        pass
      else:
        if [x,y] not in seen:
          seen.append([x,y])
          que.append([x,y])
          dist[y][x]=dist[l[1]][l[0]]+1
  return dist[gy][gx]

d=BFS(maze,[0,0],[H-1,W-1])
if d==0:
  print(-1)   # この時たどり着けない
else:
  print(H*W-(d+1)-b)

Measured memory_bytes: 3564
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int k = scan.nextInt();
		int max = 0;

		if (k <= a) {
			max = k;
		} else if (k <= (a + b)) {
			max = a;
		} else {
			max = a - (k - a - b);
		}

			System.out.print(max);

	}
}


Measured memory_bytes: 35604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S, ans="AC";
  cin >> S;
  int L = S.size();
  if(S[0] != 'A') ans = "WA";
  int cnt=0;
  for(int i=1;i<L;i++) {
    if(isupper(S[i])) {
      if(i==1 || i==L-1 || S[i] != 'C') ans="WA";
      cnt++;
    }
  }
  if(cnt!=1) ans="WA";
  cout << ans << endl; 
}

Measured memory_bytes: 256
N,*B,=open(0).read().split()
N=int(N)
B=list(map(int,B))
ans=B[0]
if N==2:
    ans+=B[0]
else:
    for i in range(N-2):
        ans+=min(B[i],B[i+1])
    ans+=B[N-2]
print(ans)


Measured memory_bytes: 9108
//Author: AnandRaj anand873
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 
 
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test(t) int t;cin>>t;while(t--)
#define forn(i,f,n) for(int i=f;i<f+n;i++)
#define rforn(i,l,n) for(int i=l;i>l-n;i--)
#define all(v) v.begin(),v.end()
#define prin(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int i=f;i<f+n;i++) cin>>V[i]
 
const int MOD = 1e9+7,MAX = 1e5+5;
/////////////////FastExp///////////////////
ll powN(ll a,ll p,ll mod)
{
	if(p==0) return 1;
	ll z=powN(a,p/2,mod);
	z=(z*z)%mod;
	if(p%2) z=(z*a)%mod;
	return z;
}
/////////////////FastExp///////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX+1, true);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
        	for (j = i * i; j <= MAX; j += i)
            	is_prime[j] = false;
    	}
	}
}
//////////////////Sieve////////////////////

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

Measured memory_bytes: 256
a = str(input())
if a == 'a' or a == 'b' or a == 'c' or a == 'd' or a =='e' or\
a == 'f' or a == 'g' or a == 'h' or a == 'i' or a =='j' or\
a == 'k' or a == 'l' or a == 'm' or a == 'n' or a =='o' or\
a == 'p' or a == 'q' or a == 'r' or a == 's' or a =='t' or\
a == 'u' or a == 'v' or a == 'w' or a == 'x' or a =='y' or a == 'z':
    print('a')
else:
    print('A')

Measured memory_bytes: 61712
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  string s;
  cin >> s;
  
  int count = 0;
  for(int i = 0; i < 3; i++){
    if(s.at(i) == 'o'){
      count++;
    }
  }
  
  cout << 700 + 100 * count << endl;
}

Measured memory_bytes: 3560
#include<stdio.h>
int main(){
  int n,sum=0,i,j,p;
  scanf("%d",&n);
  int d[n];
  for(i=0;i<n;i++)
    scanf("%d",&d[i]);
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
	p=d[i]*d[j];
	sum=sum+p;
    }
  }
  printf("%d\n",sum);
  return 0;}


Measured memory_bytes: 128
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(int i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

ll MOD = 1000000007;
ll mod(ll x) { return (x%MOD + MOD) % MOD; }

long long inverse(long long mod, long long val) {
	long long x[2] = { mod, val };
	long long a[2] = { 1, 0 };
	long long i;
	for (i = 0; x[!i]; i ^= 1) {
		a[!i] -= x[i] / x[!i] * a[i];
		x[i] = x[i] % x[!i];
	}
	if (!i) a[!i] += mod;
	return a[!i];
}

ll frac[510000];

ll com(ll a,ll b){
	if (a < b) return 0;
	return (((frac[a] * inverse(MOD, frac[b])) % MOD) * inverse(MOD, frac[a - b])) % MOD;
}

ll p(ll a, ll b) {
	if (a < b) return 0;
	return (frac[a] * inverse(MOD, frac[a - b])) % MOD;
}

int main() {
	ll n, m;
	cin >> n >> m;

	ll x = 1;
	frac[0] = 1;
	for (int i = 1; i < 510000; ++i) {
		x *= i;
		x %= MOD;
		frac[i] = x;
	}

	ll ret = 0;
	for (int i = 0; i <= n; ++i) {
		ll a = com(n, i) * p(m - i, n - i) * (i % 2 == 0 ? 1 : -1);
		a = mod(a);
		a *= p(m, n);
		a = mod(a);
		ret += a;
		ret = mod(ret);
	}
	PRI(ret);
	return 0;
}




Measured memory_bytes: 7608
N,K=map(int,input().split())
A=list(map(int,input().split()))
num=sum(A)
L=[]
cnt=0
for i in range(2,10**5+1):
    while num%i==0:
        num//=i
        cnt+=1
    if cnt>0:
        L.append([i,cnt])
        cnt=0
if num>1:
    L.append([num,1])
#print(L)
import copy
L1=[1]
L2=[]
for i in range(len(L)):
    for j in range(len(L1)):
        for k in range(L[i][1]+1):
            L2.append(L1[j]*L[i][0]**k)
    L1=copy.deepcopy(L2)
    L2=[]
L1.sort(reverse=True)
#print(L1)

for i in range(len(L1)):
    C=[]
    for j in range(N):
        C.append(A[j]%L1[i])
    C.sort(reverse=True)
    D=sum(C)
    E=0
    cnt=0
    for k in range(len(C)):
        if D==E:
            break
        else:
            D-=(C[k])
            E+=(L1[i]-C[k])
    if E<=K:
        print(L1[i])
        exit()
    #print(D,E,L1[i],C)
            

Measured memory_bytes: 44908
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef unsigned long long ull;

const int MOD = 1000000007 ; //  , 1000000009 , 1000000023 ,998244353
const ll INF = ll(1e18);
const ld PI = 4*atan((ld)1);

ll power(ll x,ll n) {
  ll result=1;
  while(n>0){
    if(n&1)result = (result * x)%MOD;
    x=(x*x)%MOD;
    n >>= 1;
  }
  return result%MOD;
}
ll gcd(ll a,ll b){
  if(a==0)return b;
  return gcd(b%a,a);
}
int main() {
  #ifdef AVI  
    freopen("input.txt" , "r" , stdin);
  #endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);

  ll n;
  cin >> n;
  map<string,ll>ar;
  set<string>st;
  for(ll itr=0 ; itr<n ; itr++){
    string s;
    cin >> s;
    sort(s.begin() , s.end());
    ar[s]++;
    st.insert(s);
  }
  ll res = 0;
  //cout << res;
  for(auto &x:st){
    //cout << x  << ' ';
    res += (ar[x]*(ar[x]-1))>>1;
  }
  cout << res;
}

Measured memory_bytes: 20608
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

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

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using ul = unsigned long long;
using Bint = mp::cpp_int;
ll mod = 1000000007;

int main() {
source:
    string s;
    cin >> s;
    if (s[0] == s[1] && s[1] == s[2]) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define deb(x) cerr<<"["<<#x<<": "<<x<<"]"<<endl;
#define endl '\n'
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define per(i,a,b) for(auto i=a;i>b;i--)
#define get(v) for(auto &i:v) cin>> i;
#define print(v) for(auto i:v) cout<<i<<" ";
#define all(x) x.begin(),x.end()
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MOD 1000000007
void solve(){
    int k;
  cin>>k;
  string s = "ACL";
    --k;
  while(k--){
    //deb(k)
    s += "ACL" ;
  //  deb(s)
  }
  cout<<s;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
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 INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    ll N, M, X; cin >> N >> M >> X;
    vector<ll> c(N);
    vector<vector<ll>> a(N, vector<ll>(M));
    for (int i = 0; i < N; ++i) {
        cin >> c[i];
        for (int j = 0; j < M; ++j) {
            cin >> a[i][j];
        }
    }

    ll ans = INF;
    for(ll bit = 0; bit < (1 << N); ++bit){
        ll tmp = 0;
        vector<ll> score(M);
        for (int i = 0; i < N; ++i) {
            if(bit & (1<<i)){
                tmp += c[i];
                for (int j = 0; j < M; ++j) {
                    score[j] += a[i][j];
                }
            }
        }
        bool f = true;
        for (int i = 0; i < M; ++i) {
            if(score[i] < X) f = false;
        }
        if(f) ans = min(ans, tmp);
    }
    if(ans == INF) ans = -1;
    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: 3600