akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    int n,T;
    cin >> n >> T;
    int c,t;
    vector<pair<int,int> >cost(n);
    REP(i,n){
        cin >> c >> t;
        cost[i]=make_pair(c,t);
    }
   
    sort(cost.begin(),cost.end());
    
    int answer=-1;
    REP(i,n){
        if(cost[i].second <= T){
            answer=cost[i].first;
            break;
        }
    }
    
    if(answer==-1)cout << "TLE" << endl;
    else cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
        h: i64,
        w: i64,
        ab: [(i64, i64); n],
    }

    println!(
        "{:?}",
        ab.iter().filter(|&(a, b)| (a / h) * (b / w) != 0).count()
    );
}


Measured memory_bytes: 2240
N,M = map(int,input().split())
A_pre = [int(input()) for _ in range(M)]
mod_num = 1000000007

A = []
if len(A_pre)>0:
    A.append(A_pre[0])
    for i in range(1,M):
        if A[-1] != A_pre[i]:
            A.append(A_pre[i])
      

ans = [0] * (N+1)
ans[0] = 1
break_floor_count = 0
if break_floor_count < M and A[break_floor_count] == 1:
    break_floor_count += 1
else:
    ans[1] = 1

for i in range(2,N+1):
    if break_floor_count < M and A[break_floor_count] == i:
        break_floor_count += 1
    else:
        ans[i] = (ans[i-2]+ans[i-1])%mod_num 

print(ans[N])


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

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

using namespace std;
using ll = long long;

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

    ll h,n,l=0,sum = 0;
    cin >> h >> n;
    vector<int> v(n);
    rep(i,n){   
        cin >> v.at(i);
        sum += v.at(i);
    }
    if(sum >= h) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int c = 0;
  int left = 0;
  for (int i = 0; i < N; i++){
    if (S[i] == '('){
      c++;
    } else {
      c--;
      left = max(left, -c);
    }
  }
  c = 0;
  int right = 0;
  for (int i = N - 1; i >= 0; i--){
    if (S[i] == ')'){
      c++;
    } else {
      c--;
      right = max(right, -c);
    }
  }
  for (int i = 0; i < left; i++){
    cout << '(';
  }
  cout << S;
  for (int i = 0; i < right; i++){
    cout << ')';
  }
  cout << endl;
}

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

int main(void) {
    string s;
    int ans = 0;
    cin >> s;

    int length = s.length();
    int halfLength = length / 2;

    for (int i = 0; i < halfLength; ++i) {
        if (s[i] != s[length - 1 - i]) ans++; 
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    int a, b;
    string aa, bb;
    vector<string> A(2);

    cin >> a >> b;

    aa = to_string(a);
    bb = to_string(b);

    rep(i, b) {
        A[0] += aa;
    }

    rep(i, a) {
        A[1] += bb;
    }

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

    cout << A[0] << endl;

    return 0;
    
}

Measured memory_bytes: 256
#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-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#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 vector<string> vs;
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;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;

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


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

    int n; cin >> n;
    int a;
    bool can = 0;
    rep(i,n) {
        cin >> a;
        if(a%2!=0){
            can = true; break;
        }
    }
    cout << (can? "first" : "second") << '\n';
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	n := 0
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	ans := 0
	prev := -1
	c := 1
	for i := 0; i < n; i++ {
		if a[i] == prev {
			c++
		} else {
			if c > 0 {
				ans += c / 2
				c = 1
			}
		}
		prev = a[i]
	}
	if c > 0 {
		ans += c / 2
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int L;
int l[65],r[65],w[65],N,M;
void ins(int ll,int rr,int ww){
	l[++M]=ll;r[M]=rr;w[M]=ww;
}
int main(){
	register int i;
	scanf("%d",&L);N=1;
	while(L){
		if(L&1) ins(N,-1,L-1),L--;
		else ins(N,N+1,L>>1),ins(N,N+1,0),N++,L>>=1;
	}
	printf("%d %d\n",N,M-1);
	for(i=1;i<M;i++) printf("%d %d %d\n",l[i],r[i]==-1?N:r[i],w[i]);
}

Measured memory_bytes: 256
require 'prime'
n = gets.strip.to_i

if n==1
  p 1
  exit
end

dividers = [0]*(n+1)
(1..n).each do |num|
  Prime.prime_division(num).each do |index, multi|
    dividers[index] += multi
  end
end

MOD = 10**9+7
result = dividers.select {|v| v>0 }.map {|e| e+1 }.inject {|m,v| (m*v)%MOD }
p result

Measured memory_bytes: 2300
x = input()
if x =='hi':
  print('Yes')
elif x =='hi'*2:
  print('Yes')
elif x =='hi'*3:
  print('Yes')
elif x =='hi'*4:
  print('Yes')
elif x =='hi'*5:
  print('Yes')
else:
  print('No')
  

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

// THINK: INT vs LONG LONG?

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

	int x;
	cin >> x;
	ll ans = 0;
	ans += 1000 * (x / 500);
	x  %= 500;
	ans += 5 * (x / 5);
	cout << ans << endl;

	return 0;
}

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

using namespace std;

int n,d;

int main()
{
	scanf("%d%d",&n,&d);
	if(n%(2*d+1)==0)
	    printf("%d\n",n/(2*d+1));
	else
	    printf("%d\n",n/(2*d+1)+1);
	return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
using namespace std;

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

	int c = 0;
	for (int i = 1; i <= n; i += 2) {
		c++;
	}

	if (c >= k) printf("YES\n");
	else printf("NO\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i,N) cin >> a[i];

  vector<ll> d(N+1);
  map<ll,ll> mp;
  d[0] = 0;
  rep(i,N) {
    d[i+1] = d[i] + a[i];
    auto it = mp.find(d[i+1]);
    if(it != mp.end()) it->second++;
    else {
      mp.insert(make_pair(d[i+1],1));
    }
  }

  ll res = 0;
  if(mp.size()) {
    auto it = mp.find(0);
    if(it != mp.end()) res += it->second;
    for(auto it:mp) {
      res += it.second * (it.second - 1) / 2;
    }
  }

  cout << res << endl;
}


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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> h(n+1);
    for (int i = 1; i <= n; ++i) cin >> h[i];
    int ans = 0, hh = h[0];
    for (int i = 1; i <= n; ++i) {
        if (h[i] >= h[i-1]) {
            if (i == n) ans += h[i] - hh;
            continue;
        }
        ans += h[i-1] - hh;
        hh = h[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(a)			a.begin(), a.end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF				2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)	((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define	MAX_QWORD		((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI			3.14159265358979323846
typedef long long		ll;
typedef pair<ll, ll>	P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	REP(i, N) cin >> A[i];
	
	ll ans = 0;
	ll sumOne = 0;
	int rCnt = 0;
	for (int lCnt = 0; lCnt < N; lCnt++) {
		for (; rCnt < N; rCnt++) {
			if (sumOne + A[rCnt] == (sumOne ^ A[rCnt])) {
				sumOne += A[rCnt];
			} else {
				break;
			}
		}
		sumOne -= A[lCnt];
		ans += (rCnt - lCnt);
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 1024
n, m = [int(elem) for elem in input().split()]
h_lst = [int(elem) for elem in input().split()]

res = [1] * n

for i in range(m):
    a, b = [int(elem) for elem in input().split()]
    if h_lst[a-1] > h_lst[b-1]:
        if res[b-1] != 0:
            res[b-1] -= 1
    elif h_lst[a-1] < h_lst[b-1]:
        if res[a-1] != 0:
            res[a-1] -= 1
    else:
        if res[a-1] != 0:
            res[a-1] -= 1
        if res[b-1] != 0:
            res[b-1] -= 1
print(sum(res))


Measured memory_bytes: 19988
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int i,j,k,n,m,a,b,c,d;
int main(){
	while (scanf("%d%d%d%d",&a,&b,&c,&d)!=EOF){
		printf("%d\n",max(a*b,c*d));
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF 2147483647//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    int n;
    cin >> n;
    vector<string> siritori(n,"");
    rep(i,n){
        cin >> siritori.at(i);
    }
    rep(i,n){
        if(i != 0){
            if(siritori[i-1][siritori[i-1].length()-1]  != siritori[i][0]){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    sort(siritori.begin(),siritori.end());
    rep(i,n-1){
        if(siritori[i] == siritori[i+1]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
/**
  * @brief atcoder
  * @author yao
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>
#define ft first
#define sd second
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#   define NDEBUG
#endif //DBG
#include <cassert>

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

#define N 512
#define M 32
#define K 2097152
#define T 1024

int c[M];
int s[N][M];
int t[N];
int l[M];
int sc;

const int n = 365, m = 26;

int count()
{
    int ct = 0;
    memset(l,-1,sizeof(l));
    int res = 0;
    for(int i=0;i<n;++i)
    {
        ct += sc;
        ct -= (i-l[t[i]]) * c[t[i]];
        l[t[i]] = i;
        res += s[i][t[i]];
        res -= ct;
    }
    return res;
}

int main()
{
    int d;
    scanf("%d", &d);
    assert(d == 365);
    for(int i=0;i<m;++i) scanf("%d", &c[i]), sc += c[i];
    for(int i=0;i<n;++i)for(int j=0;j<m;++j) scanf("%d", &s[i][j]);
    for(int i=0;i<n;++i) t[i] = rand() % m;
    int val = count();
    //dbg_pri("poi 1: %d\n", val);
#ifdef DBG
    int ca=0, cb=0;
#endif //DBG
    for(int i=0;i<K;++i)
    {
        int x = rand()%n, k = rand()%m;
        int pre_t = t[x];
        t[x] = k;
        int nxt_v = count();
        if(nxt_v >= val || rand() <= (int)(exp((double)(nxt_v-val)/T)*((lli)RAND_MAX+1)))
        {
#ifdef DBG
            (nxt_v < val ? ca : cb) ++;
#endif //DBG
            val = nxt_v;
            //dbg_pri("poi 2: %d %d\n", i, val);
        }
        else t[x] = pre_t;
    }
    for(int i=0;i<n;++i) printf("%d\n", t[i]+1);
    dbg_pri("poi 3: %d %d %d\n", val, ca, cb);
    return 0;
}


Measured memory_bytes: 2736
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
typedef long long ll;
const ll inf = 4e18;
const ll mod = 1e9+7;
#define print(X) cout << (X) << endl
#define all(c) (c).begin(),(c).end()

void solve()
{
    ll A,B,C;
    cin >> A >> B >> C;
    vector<ll> list = {A,B,C};
    sort(all(list));
    ll n = (list[2]-list[0])+(list[2]-list[1]);
    ll ans=n/2;
    if (n%2==1) {
        ans+=2;
    }
    print(ans);
}

int main()
{
    solve();
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<cstring>
using namespace std;
int main(){
    int count = 0;
string A,B;
cin>>A>>B;
for(int i=0;i<3;i++){
    if(A[i] == B[i]){
      count++;
    }
}
cout<<count<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, b) for(int i = a; i < b; i++)
#define REP_(i, a, b) for(int i = a; i <= b; i++)
#define sl(n) scanf("%lld", &n);
#define si(n) scanf("%d", &n);
#define RepAll(a) for(auto x: a)
#define cout(ans) cout << ans << endl;
typedef long long ll;
int link[210][210], rr[210];
int a, b, c;
using namespace std;
int main()
{
    //cout << 0x3f << endl;
    memset(link, 0x3f, sizeof(link)); //cout << link[2][2] << endl;
    int n, m, r;
    scanf("%d%d%d", &n, &m, &r);
    for(int i = 0; i < r; i++)
    {
        scanf("%d", &rr[i]), rr[i]--;
    }

    sort(rr, rr+r);
    for(int i = 0; i < m; i++)
    {
        scanf("%d%d%d", &a, &b, &c);
        link[--a][--b] = link[b][a] = c;
    }
    int ans = 0;
    for(int k = 0; k < n; k++)
    {
        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < n; j++)
            {
                link[i][j] = min( link[i][j], link[i][k] + link[k][j]);
            }
        }
    }
    int mi = INT_MAX;
    do
    {
        int ans = 0;

        for(int i = 0; i + 1 < r; i++)
        {
            ans += link[rr[i]][rr[i+1]];

        }
        mi = min(ans, mi);
    }
    while(next_permutation(rr, rr + r));
    cout << mi << endl;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define prints(x, y) cout<<(x)<<" "<<(y)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  string a, b;
  cin >> a >> b;

  rep(i, b.size()){
    cout << a[i] << b[i];
  }

  if(a.size()!=b.size()) cout << a[a.size()-1];
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
#define int long long
int p[100005], n, k, q, x;
main() {
    DAU
    cin >> n >> k >> q;
    k -= q;
    while (q--) {
        cin >> x;
        ++p[x];
    }
    for (int i = 1; i <= n; ++i) {
        p[i] += k;
        if (p[i] > 0)
            cout << "Yes\n";
        else cout << "No\n";
    }
    PLEC
}


Measured memory_bytes: 4388
N = int(raw_input())
S = list(raw_input())
ans = 0
for n in range(N):
 B = set(S[:n])
 E = set(S[n:])
 c = 0
 for b in B:
  if b in E:
   c += 1
 if c > ans:
  ans = c
print ans


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int n; cin >> n;
    V<tuple<string, int, int> > a;
    for(int i = 1; i <= n; i++){
        string s; cin >> s;
        int p; cin >> p;
        p *= -1;
        a.push_back(tie(s, p, i));
    }

    sort(ALL(a));

    for(int i = 0; i < n; i++){
        cout << get<2>(a[i]) << endl;
    }



    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main(void){
  int n;
  vector<double> a(100);

  cin >> n;
  for(int i = 0; i < n; i ++){
    cin >> a.at(i);
  }

  double ave;
  double sum = 0;

  for(int i = 0; i < n; i ++){
    sum += a.at(i);
  }
  ave = sum/n;

  double min = 999;
  int min_index = 999;
  for(int i = 0; i < n; i ++){
    double temp = abs(ave - a.at(i));
    if(min > temp){
      min = temp;
      min_index = i;
    }
  }

  cout << min_index << endl;

  return 0;
}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n; cin >> n;
    vector<char> c(n);
    rep(i,n)cin >> c[i];
    rep(i,n){
        if(c[i] == 'Y'){
            out("Four");
            return 0;
        }
    }
    out("Three");
}


Measured memory_bytes: 256
import heapq

n = int(input())
s = list(map(int, input().split()))

maxn = (2**(n+1)) - 1
tree = [0] * maxn

s = sorted(s)

h = []
heapq.heappush(h, 0)
error = False

i = len(s) - 1
while i >= 0:
    count = 1
    while i >= 0 and s[i-1] == s[i]:
        count += 1
        i -= 1
    if len(h) < count:
        error = True
        break
    dh = []
    for _ in range(count):
        dh.append(heapq.heappop(h))
    for hi in dh:
        while hi*2+2 < maxn:
            heapq.heappush(h, hi*2+1)
            hi = hi*2+2
    i -= 1

if error:
    print('No')
else:
    print('Yes')



Measured memory_bytes: 120524
using System;
using System.Collections.Generic;

public class Program333
{
    public static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());

        var xy = Console.ReadLine().Split(' ');
        var f = new Dictionary<int, int>();
        var s = new Dictionary<int, int>();
        for (int i = 0; i < n; i = i + 2)
        {
            var n1 = int.Parse(xy[i]);
            var n2 = int.Parse(xy[i + 1]);
            if (f.ContainsKey(n1))
            {
                f[n1]++;  //todo
            }
            else
            {
                f.Add(n1, 1);
            }

            if (s.ContainsKey(n2))
            {
                s[n2]++;  //todo
            }
            else
            {
                s.Add(n2, 1);
            }
        }

        var second = new KeyValuePair<int, int>();
        foreach (var skv in s)
        {
            if (second.Value < skv.Value)
            {
                second = skv;
            }
        }

        var maxN1Count = 0;
        foreach (var kv in f)
        {
            var maxN2Count = 0;
            if (kv.Key != second.Key)
            {
                maxN2Count = second.Value;
            }
            else
            {
                foreach (var skv in s)
                {
                    if (skv.Key != kv.Key)
                    {
                        if (maxN2Count < skv.Value)
                        {
                            maxN2Count = skv.Value;
                        }

                    }
                }

            }


            if (maxN1Count < kv.Value + maxN2Count)
            {
                maxN1Count = kv.Value + maxN2Count;
            }
        }


        var result = n - maxN1Count;
        Console.WriteLine(result);


    } // Main
}     // Class





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


int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a + b + c >= 22) cout << "bust" << endl;
  else cout << "win" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> v(N);
  for(int i=0;i<N;i++){
    cin >> v.at(i);
  }
  std::sort(v.begin(),v.end());
  cout << v.at(N-1) - v.at(0) << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <string.h>
#include <math.h>
#include <map>

using namespace std;

int main(){
	int N, ans;
	cin >> N;

	for (int i = 0; i < 10; ++i){
		int j = i + 1;
		if (N > i * 100 + i * 10 + i * 1 && N <= j * 100 + j * 10 + j * 1){
			cout << j * 100 + j * 10 + j * 1 << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	int x[200000]={};
	int y[200000]={};
	for(int i=0;i<n;i++){
		cin>>x[i];
		y[i]=x[i];
		}
	sort(y,y+n);
	for(int i=0;i<n;i++){
		if(x[i]<y[n/2]){
			cout<<y[n/2]<<endl;
		}
		else{
			cout<<y[n/2-1]<<endl;
		}
	}
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i = x; i < n; i++)
#define MAX 100
#define INF 1e18

int n,q,k;

// char X[100][100];
// int dp[1000000001];
long long d[100001];
bool processed[100001];
vector<pair<int,long long>> adj[100001];

void dijkstra(int x) {
    priority_queue<pair<long long,int>> q;
    d[x] = 0;
    q.push({0,x});
    while(!q.empty()) {
        int a = q.top().second; q.pop();
        // cout <<a << endl;
        if (processed[a]) continue;
        processed[a] = true;
        for (auto u: adj[a]) {
            
            int b = u.first, w = u.second;
            
            // cout << a << " " << b << endl;
            
            if (d[a]+w < d[b]) {
                d[b] = d[a] + w;
                q.push({-d[b],b});
            }
        }
    }
}


int main(void){
    cin >> n;
    REP(i,1,n+1) {
        d[i] = INF;
    }
    
    
    REP(i,0,n - 1) {
        int a,b,c;
        cin >> a >> b >> c;
        adj[a].push_back({b,c});
        adj[b].push_back({a,c});
    }
    
    cin >> q >> k;
    
    dijkstra(k);
    
    REP(i,1,n+1) {
        // cout << d[i] << endl;
    }
    
    REP(i,0,q) {
        int x,y;
        cin >> x >> y;
        cout << d[x] + d[y] << endl;
    }
    

}

Measured memory_bytes: 11120
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
   int c[3][3],gap[2];
   for(int i=0;i<3;i++){
       for(int j=0;j<3;j++){
           cin>>c[i][j];
       }
   }
   int sum1=c[0][0]+c[1][0]+c[2][0];
   int sum2=c[0][1]+c[1][1]+c[2][1];
   int sum3=c[0][2]+c[1][2]+c[2][2];
   gap[0]=sum2-sum1;
   gap[1]=sum3-sum2;
   int count=0;
   for(int i=0;i<3;i++){
      for(int j=0;j<2;j++) {
        if(c[i][j+1]==(c[i][j]+(gap[j]/3))){count++;}
      }
   }
   if((count==6)&&(gap[0]%3==0)&&(gap[1]%3==0)){cout<<"Yes"<<endl;}
   else {cout<<"No"<<endl;}
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9 + 7;

int main(void){
  ll n;
  cin >> n;
  auto v = vector<int>(n+1);
  auto res = vector<int>(n+1,-1);
  for(int i = 1;i <= n;++i){
    scanf("%d", &v[i]);
  }
  for(int i = n;i >= 1;--i){
    int calc = v[i];
    for(int j = i * 2;j <= n;j += i){
      if(res[j]){
        calc = !calc;
      }
    }
    res[i] = calc;
  }
  int total = 0;
  for(int i = 1;i <= n;++i){
    total += res[i];
  }
  printf("%d\n", total);
  if(total != 0){
    bool first = true;
    for(int i = 1;i <= n;++i){
      if(res[i]){
        if(!first){
          printf(" ");
        }else{
          first = false;
        }
        printf("%d", i);
      }
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>
using namespace std;

template <typename T>
void l(T print){
	cout << print;
}
template <typename T>
void ll(T print){
	cout << print << endl;
}
template <typename T>
void ll(vector<T> print){
	for(auto i=0; i < print.size(); i++)
		cout <<"["<<i<<"]: " << print[i] << endl;
}

void solve(int a,int b){
	int m = max(a,b);
	if(m * 2 <= 16)
		cout << "Yay!" << endl;
	else
		cout << ":(" << endl;

}

int main() {
	int a,b; cin >> a; cin >> b;
	solve(a,b);
//	solve(5,4); solve(11,4);

	return 0;
}


Measured memory_bytes: 256
S = input()
a = 0
b = 0
for n in range(len(S)):
    if n%2 == 0:
        if S[n] == '0':
            a += 1
        else:
            b += 1
    if n%2 == 1:
        if S[n] == '0':
            b += 1
        else:
            a += 1
print(min(a, b))

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

int main(){
	double fif,one;
	while(cin >> fif >> one){
		puts(	fif<35.5&&one<71.0 ? "AAA":
				fif<37.5&&one<77.0 ? "AA":
				fif<40.0&&one<83.0 ? "A":
				fif<43.0&&one<89.0 ? "B":
				fif<50.0&&one<105.0 ? "C":
				fif<55.0&&one<116.0 ? "D":
				fif<70.0&&one<148.0 ? "E":
				"NA"
		);
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main(){

    long long N, A, B, result;
    cin >> N;
    cin >> A;
    cin >> B;

    result = 0;

    if(abs(A-B) % 2 == 0){
        result = (B - A) / 2;
    }else if(A==1 || A==N || B==1 || B==N){
        result = (B - A + 1) / 2;
    }else if(A-1 > N-B){
        // Bがより右端に近い
        result += N - B + 1;
        A = A + (N - B) + 1;
        B = N;
        result += (B - A) / 2;
    }else{
        // Aがより左端に近い
        result += A - 1 + 1;
        B = B - (A - 1) - 1;
        A = 1;
        result += (B - A) / 2;
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
inline int rnd(int x){
	return (rand()<<16|rand())%x;
}
const int N=500005;
int n,f[N],g[N],d[N],q;
int main(){
	n=read(); f[0]=read();
	for(int i=1;i<=n;i++)d[i]=read();
	q=read();
	for(int i=1;i<=n;i++){
		f[i]=min(f[i-1],abs(f[i-1]-d[i]));
	}
	g[n+1]=1;
	for(int i=n;i;i--)g[i]=d[i]<2*g[i+1]?d[i]+g[i+1]:g[i+1];
	for(int i=1;i<=q;i++){
		int x=read();
		if(g[x+1]<=f[x-1])puts("YES"); else puts("NO");
	}
}
/*

*/

Measured memory_bytes: 7808
n,m,x,y = map(int,input().split())
xl = list(map(int,input().split()))
yl = list(map(int,input().split()))
z = [i for i in range(x+1,y+1)]
for i in range(len(z)):
  if max(xl) < z[i] <= min(yl):
    print("No War")
    exit()
print("War")

Measured memory_bytes: 9192
#include<bits/stdc++.h>
#define REP(i,n,N) for(ll i=(n);i<(ll)(N);i++)
#define p(s) cout<<(s)<<endl;
#define F first
#define S second
typedef long long ll;
using namespace std;

ll calc(ll k,ll l,ll r) {
	ll F=(r-1)/3-(l-1)/3;
	ll B=(r-1)/5-(l-1)/5;
	ll FB=(r-1)/15-(l-1)/15;
	ll ret=k*((r-l)-(F+B)+FB)+(F+B)*4;//num + (Fizz or Buzz)
	return ret;
}

ll C(ll n) {
	ll ret=0;
	string S=to_string(n);
	REP(i,1,S.size()) {
		ret+=calc(i,pow(10,i-1),pow(10,i));
	}
	ret += calc(S.size(),pow(10,S.size()-1),n+1);
	return ret;
}
int main() {
	ll s;
	cin>>s;
	ll lb=0, ub=1e18;
	while(ub-lb>1) {
		ll mid=(lb+ub)/2;
		if(C(mid)<=s) {
			lb=mid;
		}
		else ub=mid;
	}
	string str;
	REP(i,lb,lb+40) {
		if(str.size()>40)	break;
		if(i%15==0) str+="FizzBuzz";
		else if(i%3==0) str+="Fizz";
		else if(i%5==0) str+="Buzz";
		else str+=to_string(i);
	}
	cout<<str.substr(s-C(lb-1)-1,20)<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
#define MOD 1000000007
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

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

    int colorNum = 0;
    vector<int> ans(N-1);
    vector<vector<pair<int, int>>> graph(N);
    vector<bool> visited(N, false);
    int a, b;
    for(int i=0; i<N-1; i++) {
        cin >> a >> b;
        a--; b--;
        graph[a].push_back({b, i});
        graph[b].push_back({a, i});
    }

    queue<pair<int, int>> q;
    q.push({0, -1});
    visited[0] = true;

    while(!q.empty()) {
        auto pr = q.front(); q.pop();
        int node = pr.first;
        int prev = pr.second;

        int color = 1;
        if(color == prev) color++;

        for(auto edge: graph[node]) {
            int next = edge.first;
            int idx = edge.second;
            if(visited[next]) continue;
            visited[next] = true;
            ans[idx] = color;
            q.push({next, color});
            chmax(colorNum, color);
            color++;
            if(color == prev) color++;
        }


    }

    cout << colorNum << endl;
    for(auto num: ans) cout << num << endl;

    return 0;
}

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

int main(){
  int w,h,x,y; cin>>w>>h>>x>>y;
  cout<<(double(w)*double(h))/2.0<<' ';
  if(x+x==w&&y+y==h){
    cout<<1;
  }else{
    cout<<0;
  }cout<<endl;
}

Measured memory_bytes: 256
#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;
typedef unsigned long long ull;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

int main() {
	ll l = read, r = read;

	if(l == r) return puts("1"), 0;

	int k = 63 - __builtin_clzll(ull(l ^ r));

	debug("%d\n", k);

	l &= (2ll << k) - 1;
	r &= (2ll << k) - 1;

	debug("%lld %lld\n", l, r);

	int d = r == (1ll << k) ? 0 : 64 - __builtin_clzll(ull(r ^ (1ll << k)));

	debug("%d\n", d);

	ll l1 = l, r1 = (1ll << k) + (1ll << d) - 1;
	ll l2 = (1ll << k) + l, r2 = (1ll << k << 1) - 1;

	debug("%lld %lld %lld %lld\n", l1, r1, l2, r2);

	if(l2 <= r1) printf("%lld\n", r2 - l1 + 1);
	else printf("%lld\n", r2 - l2 + r1 - l1 + 2);
}


Measured memory_bytes: 128
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
int n;
pair<int,int> x[200010];
multiset<int> b,r;
ll ans;
int main()
{
	cin>>n; 
    for (int i=1;i<=n;i++)
    {
        cin>>x[i].first>>x[i].second;
        if (x[i].first>x[i].second) swap(x[i].first,x[i].second);
        b.insert(x[i].first),r.insert(x[i].second);
    }
    ans=1LL*(*b.rbegin()-*b.begin())*(*r.rbegin()-*r.begin());
    sort(x+1,x+n+1);
    for (int i=1;i<=n;i++)
    {
        b.erase(b.find(x[i].first)),r.insert(x[i].first);
        r.erase(r.find(x[i].second)),b.insert(x[i].second);
        ans=min(ans,1LL*(*b.rbegin()-*b.begin())*(*r.rbegin()-*r.begin()));
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 20608
#include<iostream>
#include<map>
#include<algorithm>
#include<string>
#include<cmath>
#include<memory.h>
#define pii pair<int,int>
using namespace std;
const int Max = 1e6 + 5;
int lst[Max];
int book[Max];
pii b[Max];

int main()
{
	string a, b, c;
	cin >> a >> b >> c;
	int a1=0, b1=-1, c1 = -1;
	char sec=a[0];
	while (1)
	{
		if (sec == 'a')
		{
			if (a1 == a.size()-1) { cout << "A";break; }
			sec = a[++a1];
		}
		else if (sec == 'b')
		{
			if (b1 == b.size()-1) { cout << "B";break; }
			sec = b[++b1];
		}
		else if (sec == 'c')
		{
			if (c1 == c.size()-1) { cout << "C";break; }
			sec = c[++c1];
		}
	}
}

Measured memory_bytes: 3116
N, M = map(int, input().split())
pnt = {}
ac = {}
for i in range(M):
	p,s = input().split()
	p = int(p)
	if not p in pnt:
		pnt[p] = 0
		ac[p] = 0
	if s == "WA" and ac[p] == 0:
		pnt[p] += 1
	elif s == "AC" and ac[p] == 0:
		ac[p] += 1

for i in pnt:
	if pnt[i] != 0 and ac[i] == 0:
		pnt[i] = 0

print(sum(ac.values()),sum(pnt.values()))

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

using namespace std;

int main(){
 
string s;
int n; cin >> n;
cin >> s;
int len = s.length();
for (int i = 0; i < len; ++i)
{
    if (s[i] + n%26 <='Z')
    {
       s[i] +=n%26;
      
    }
    else s[i] = 'A'+s[i] + n%26 -'Z'-1;
}

cout << s;
return 0;
}


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

int main()
{
	char a, b, c, d;
	cin >> a >> b >> c >> d;
	if ((a == b && c == d&&a!=c) || (a == c && b == d&&a!=b) || (a == d && b == c&&a!=b))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <thread>

using namespace std;

struct Spel {
	char c;
	int  d;
};

bool is_fall_dir(const string&s, const int n, const int p, const int dir, const vector<Spel>& spels)
{
	int c_p = p;

	for (auto &spel : spels) {
		if (spel.c != s[c_p]) continue;

		if (spel.d == -1) c_p--;
		if (spel.d == 1)  c_p++;

		if (c_p < 0)  return (dir == -1);
		if (n <= c_p) return (dir == 1);
	}

	return false;
}

int search_fallpos(const string&s, const vector<Spel>& spels, int n, int dir)
{
	int alive, fall;
	if (dir == 1) {
		alive = 0;
		fall  = n - 1;
	}
	else {
		alive = n - 1;
		fall  = 0;
	}

	if (is_fall_dir(s, n, alive, dir, spels)) return alive;
	if (!is_fall_dir(s, n, fall, dir, spels)) return -1;

	while (abs(fall - alive) != 1) {
		int m = (fall + alive) / 2;
		if (is_fall_dir(s, n, m, dir, spels)) {
			fall = m;
		}
		else {
			alive = m;
		}
	}

	return fall;
}

int main()
{
	int n, q; cin >> n >> q;
	string s; cin >> s;
	
	vector<Spel> spels(q);
	for (auto& spel : spels) {
		char c, d;
		cin >> c >> d;

		spel.c = c;
		spel.d = (d == 'L') ? -1 : 1;
	}

	int r_pos = search_fallpos(s, spels, n, 1);
	int l_pos = search_fallpos(s, spels, n, -1);

	int fall_r = (r_pos != -1) ? (n - r_pos) : 0;
	int fall_l = (l_pos != -1) ? l_pos + 1 : 0;

	int fall_count = min(n, fall_l + fall_r);
	cout << (n - fall_count) << endl;

	return 0;
}

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

int main() {
	int R, G, B, N, ans = 0;
	cin >> R >> G >> B >> N;
	for (int i = 0; i <= N; ++i) {
		for (int j = 0; j <= N; ++j) {
			if ((N - R * i - G * j) % B == 0 && R * i + G * j <= N) ++ans;
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl

const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, long long C){
  bool f = (A == B) or (B == C) or (C == A);
  f = f ? !(A == B and B == C) : f;
  cout << (f ? YES : NO) << endl;
}

signed main(){
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  long long C;
  scanf("%lld",&C);
  solve(A, B, C);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll>kaijou;
ll extgcd (ll a, ll b, ll& x, ll& y) {
  ll d = a;
  if (b != 0ll) {
    d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  } else {
    x = 1;
    y = 0;
  }
  return d;
}
ll flip (ll a) {
  ll m = 1e9 + 7;
  ll x, y;
  ll p = extgcd(a, m, x, y);
  return (m + x % m) % m;
}
ll cmp (ll a, ll b) {
  ll m = 1e9 + 7;
  ll ret = kaijou[a];
  ret *= flip(kaijou[b]);
  ret %= m;
  ret *= flip(kaijou[a - b]);
  ret %= m;
  return ret;
}
int main () {
  ll m = 1e9 + 7;
  kaijou.resize(10000);
  kaijou[0] = 1ll;
  for (int i = 1; i < 10000; i ++) {
    kaijou[i] = kaijou[i - 1] * i;
    kaijou[i] %= m;
  }
  ll S;
  cin >> S;
  ll ans = 0ll;
  for (ll i = 1; i * 3 <= S; i ++) {
    ll kj = S - i * 3;
    ans += cmp(kj + i - 1, kj);
    ans %= m;
  }
  cout << ans << endl;
}


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

#include <atcoder/all>
#define For(i, a, b) for (int(i) = (int)(a); (i) < (int)(b); ++(i))
#define rFor(i, a, b) for (int(i) = (int)(a)-1; (i) >= (int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
using namespace atcoder;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T div_floor(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a >= 0 ? a / b : (a + 1) / b - 1;
}
template <class T>
T div_ceil(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a > 0 ? (a - 1) / b + 1 : a / b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main() {
    int n, q;
    scanf("%d%d", &n, &q);
    fenwick_tree<lint> ft(n);
    lint a[n];
    rep(i, n) scanf("%lld", &a[i]), ft.add(i, a[i]);
    rep(_, q) {
        int t, x, y;
        scanf("%d%d%d", &t, &x, &y);
        if (t == 0)
            ft.add(x, y);
        else
            printf("%lld\n", ft.sum(x, y));
    }
}

Measured memory_bytes: 12140
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define ll long long
#define pp pair<ll,ll>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
ll max(ll x, ll y)
{
    return x>y ? x : y;
}
ll min(ll x, ll y)
{
    return x<y ? x : y;
}
void _(ll&a , ll b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b,m;cin >> a >> b >> m;
    ll ar[a];
    for (int i = 0; i < a; ++i)
    {
        cin >> ar[i];
    }
    ll br[b];
    for (int i = 0; i < b; ++i)
    {
        cin >> br[i];
    }
    ll ans=1e18;
    for (int i = 0; i < m; ++i)
    {
        ll x,y,c;cin >> x >> y >> c;x--;y--;
        ans=min(ans,ar[x]+br[y]-c);
    }
    sort(ar,ar+a);
    sort(br,br+b);
    ans=min(ans,ar[0]+br[0]);
    cout << ans;
    }

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

R dp[3010][3010];

int main(void){
	int n;
	cin >> n;

	dp[0][0] = 1.0;
	rep(i,n){
		R p;
		cin >> p;
		rep(j,i+1){
			dp[i+1][j+1] += p * dp[i][j];
			dp[i+1][j] += (1.0 - p) * dp[i][j];	
		}
	}

	R ans = 0.0;
	rep(j,n+1) if(j > n - j) ans += dp[n][j];
	cout.precision(20);
	cout << fixed << ans << endl;
	return 0;
}

Measured memory_bytes: 139648
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
A = list(map(int,input().split()))
# + - + - のパターン
ans1 = 0
acum = 0
for i in range(n):
  pre_plus = i % 2 == 0
  acum += A[i]
  if (pre_plus and acum < 0) or (not pre_plus and acum > 0):pass
  elif not pre_plus:
    ans1 += 1-acum
    acum = 1
  else:
    ans1 += abs(acum-(-1))
    acum = -1
  # print(i,acum,ans1)

# + - + - のパターンnogyaku
ans2 = 0
pre_plus = 1
acum = 0
for i in range(n):
  pre_plus= i % 2 == 1
  acum += A[i]
  if (pre_plus and acum < 0) or (not pre_plus and acum > 0):pass
  elif not pre_plus:
    ans2 += 1-acum
    acum = 1
  else:
    ans2 += abs(acum-(-1))
    acum = -1

print(min(ans1,ans2))
# print(ans1,ans2)


Measured memory_bytes: 70896
#include <cstdio>
#include <map>
using namespace std;int main(){
  int n[1501], m[1501],o,cn,cm,i,j,x;
for(;scanf("%d %d", &cn, &cm),cn;printf("%d\n",o)){
  map<int,int> point;
  map<int,int>::iterator p;

  n[0]=m[0]=o=0;

  for(i=0;i<cn;i++){
    scanf("%d", &x);
    n[i+1]=n[i]+x;
  }
  for(i=0;i<cm;i++){
    scanf("%d", &x);
    m[i+1]=m[i]+x;
  }
  
  for(i=0;i<=cn;i++){
    for(j=0;j<=cm;j++){
	  point[n[i]+m[j]]++;
	}
  }
  
  for(p=point.begin(); p!=point.end(); p++){
	o+=(p->second)*((p->second)-1)/2;
  }
}
}

Measured memory_bytes: 18000
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();

		int sum = 0;
		String reString = "";
		
		for(int i = 0; i < 2 ;i ++) {
			if(a > b) {
				sum = sum + a;
				a--;
			} else {
				sum = sum + b;
				b--;
			}
		}
		reString = "" + sum;
		System.out.println(reString);
	}
}

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

int main()
{
    ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

    int n, x, t;

    cin >> n >> x >> t;

    double z = ceil(n/double(x));

    cout << int(z*t);

}


Measured memory_bytes: 3600
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author TM
 */


#include <bits/stdc++.h>

using namespace std;

class CStrawberryCakes {
public:
  void solve(std::istream &cin, std::ostream &cout) {
    int64_t h, w, k;
    cin >> h >> w >> k;
    vector<string> vec(h);
    for (int i = 0; i < h; ++i) cin >> vec[i];
    vector<vector<int64_t>> res(h, vector<int64_t>(w, -1));
    int64_t now = 0;
    for (int i = 0; i < h; ++i) {
//      いちごが存在するのであれば
      if (find(vec[i].begin(), vec[i].end(), '#') != vec[i].end()) {
        for (int j = 0; j < w; ++j) {
          if (vec[i][j] == '#') {
            now++;
            res[i][j] = now;
          } else {
            if (j == 0)continue;
            res[i][j] = res[i][j - 1];
          }
        }
        for (int j = w - 1; j >= 0; --j) {
          if (res[i][j] == -1) res[i][j] = res[i][j + 1];
        }
//        ---------------------------------------------------
        for (int l = i - 1; l >= 0; --l) {
          if (find(vec[l].begin(), vec[l].end(), '#') != vec[l].end()) break;
          for (int j = 0; j < w; ++j) {
            res[l][j] = res[i][j];
          }
        }
        for (int l = i + 1; l < h; ++l) {
          if (find(vec[l].begin(), vec[l].end(), '#') != vec[l].end()) break;
          for (int j = 0; j < w; ++j) {
            res[l][j] = res[i][j];
          }
        }
      }
    }
    for (const auto &item: res) {
      for (const auto &item2 : item) {
        cout << item2 << " ";
      }
      cout << endl;
    }
  }
};


int main() {
    CStrawberryCakes solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 4500
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
using namespace std;
const int inf = 1e18 + 7;
const int N = 1e6 + 7;
const int md = 1e9 + 7;
void sol() {
  int n;
  cin >> n;
  double v1 = n * 1.00 / 1.08;
  v1 = floor(v1);
  int v2 = v1 + 1;
  //cout << v << "\n";
  double k1 = v1 * 1.08;
  double k2 = v2 * 1.08;
  k1 = floor(k1);
  k2 = floor(k2);
  int q1 = (int)k1;
  int q2 = (int)k2;
  if(q1 == n) cout << v1;
  else if(q2 == n) cout << v2;
  else cout << ":(";
}

int32_t main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  //cin >> T; while(T--) 
  sol();
  return 0;
}


Measured memory_bytes: 256
<?php

$abcd = fgets(STDIN);

$a = $abcd[0];
$b = $abcd[1];
$c = $abcd[2];
$d = $abcd[3];

for ($i = 0; $i < 2; $i++) {
	for ($j = 0; $j < 2; $j++) {
		for ($k = 0; $k < 2; $k++) {
			$ans = $a + ($i ? $b : -$b) + ($j ? $c : -$c) + ($k ? $d : -$d);
			if ($ans === 7) {
				echo "" . $a . ($i ? "+" : "-") .$b. ($j ? "+" : "-") .$c. ($k ? "+" : "-") . $d . "=7\n";
				return;
			}
		}
	}
}

Measured memory_bytes: 4604