akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

LL X, K, D;

void solve() {

    cin >> X >> K >> D;
    X = abs(X);

    if ((X + D - 1) / D > K) {
        cout << X - K * D << endl;
        return;
    }

    LL ans = LLINF;
    const auto tmp = (X + D - 1) / D;
    for (LL i = max(tmp - 2, 0LL); i <= min(tmp + 2, K); i++) {
        bool f = false;
        if ((K - i) % 2) {
            f = true;
        }
        chmin(ans, abs(X - D * i + (f ? D : 0)));
        chmin(ans, abs(X - D * i + (f ? -D : 0)));
    }

    cout << ans << endl;
}

int main(void) {
#ifndef ONLINE_JUDGE
    const auto in_stream = freopen("../in.txt", "r", stdin);
    if (in_stream == nullptr) {
        cerr << "ERROR!" << endl;
        return 1;
    }
#endif

    solve();

#ifndef ONLINE_JUDGE
    fclose(in_stream);
#endif
}


Measured memory_bytes: 3632
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())

num0 = 0
for _ in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                A[i][j] = 0
                num0 += 1
                if num0 >= 3:
                    if max(A[0]) == 0 or max(A[1]) == 0 or max(A[2]) == 0:
                        print("Yes")
                        exit()
                    elif A[0][0] == A[1][0] == A[2][0] == 0:
                        print("Yes")
                        exit()
                    elif A[0][1] == A[1][1] == A[2][1] == 0:
                        print("Yes")
                        exit()
                    elif A[0][2] == A[1][2] == A[2][2] == 0:
                        print("Yes")
                        exit()
                    elif A[0][0] == A[1][1] == A[2][2] == 0:
                        print("Yes")
                        exit()
                    elif A[0][2] == A[1][1] == A[2][0] == 0:
                        print("Yes")
                        exit()

print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.1415926535897932384626
#define LMAX 9223372036854775807
#define ll long long
#define fi first
#define sec second
#define pii pair<int, int>
int n, m, k, x, y, sum, a[100005];
ll ans;
int main () {
	scanf("%d", &n);
	for (int i=1; i<=n; i++) {
		scanf("%d", &a[i]);
	}
	for (int i=1; i<=n; i++) {
		ans+=min(a[i], a[i-1]);
		a[i]-=min(a[i], a[i-1]);
		ans+=a[i]/2;
		a[i]%=2;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
long long int dp[100001], h[100001];

int main(){
      int n, k;
      cin>>n>>k;
      for(int i=0; i<n; i++)
            cin>>h[i];
      dp[0]=0;
      n--;
      for(int i=1; i<=n; i++)
            dp[i]=INT_MAX;

      for(int i=1; i<=n; i++){
            for(int j=1; j<=k && j<=i; j++)
            dp[i]=min(dp[i], dp[i-j]+abs(h[i]-h[i-j]));
      }
      cout<<dp[n]<<'\n';
}

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

using namespace std;
#define EB emplace_back
#define MP make_pair
typedef long long ll;
#define rep(i, a, b) for(ll i = a; i < b; ++i)

int main() {

    ll h , n;
    cin >> h >> n;
    ll arr[n];

    rep(i, 0, n){

        cin >> arr[i];
        if(h - arr[i] <= 0) {
            cout << "Yes";
            return 0;
        }

        h -= arr[i];
    }

    cout << "No";



    return 0;
}


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

#define LL long long
#define VI vector<int>
#define VB vector<bool>
#define VL vector<long long>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

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

using namespace std;


long long to_long(long long station, long long company) {
    return station * ((long long)1e6+10) + company;
}


void dfs(LL start, vector<LL> &route, unordered_map<LL, bool> &used, unordered_map<LL, vector<LL>> &graph) {
    FOE(a, graph[start]) {
        if (used.find(a) != used.end()) { continue; }
        used[a] = true;
        route.emplace_back(a);

        dfs(a, route, used, graph);
    }

}

int solve(int N, int M, const vector<int> &P, vector<int> &Q, vector<int> &C) {

    unordered_map<LL, vector<LL>> graph;    // (駅, 会社)から到達できる(駅, 会社)のリスト
    FOR(i, 0, P.size()) {
        graph[to_long(P[i], C[i])].emplace_back(to_long(Q[i], C[i]));
        graph[to_long(Q[i], C[i])].emplace_back(to_long(P[i], C[i]));
    }

    unordered_map<LL, bool> used;

    unordered_map<int, vector<int>> station_route_graph;
    int route_id = N + 2;
    FOE(p, graph) {
        LL station_company = p.first;

        if (used.find(station_company) != used.end()) {
            continue;
        }
        vector<LL> route = {station_company};
        used[station_company] = true;
        dfs(station_company, route, used, graph);

        FOE(station, route) {
            station = station / ((long long)1e6+10);
            station_route_graph[station].push_back(route_id);
            station_route_graph[route_id].push_back(station);
        }
        route_id++;
    }

    vector<int> dist(303030, INT_MAX);
    dist[1] = 0;
    queue<int> que;
    que.push(1);
    while (not que.empty()) {
        int x = que.front(); que.pop();
        FOE(e, station_route_graph[x]) {
            if(dist[e] > dist[x] + 1) {
                dist[e] = dist[x] + 1;
                que.push(e);
            }
        }
    }

    int ans = dist[N];
    return (ans == INT_MAX ? -1 : ans / 2);

}


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

    vector<int> P(M), Q(M), C(M);
    FOR(i, 0, M) {
        cin >> P[i] >> Q[i] >> C[i];
    }

    cout << solve(N, M, P, Q, C) << endl;

    return 0;
}

Measured memory_bytes: 84084
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    K, X = il()
    B = set(range(X - K + 1, X + 1))
    A = set(range(X, X + K))
    for i in sorted(B | A):
        print(i)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3832
n = int(input())
A = list(map(int, input().split()))

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

is_prime = [True] * 1100000

is_prime[0] = is_prime[1] = False

for i in range(2, 1100000):
    if not is_prime[i]:continue
    for j in range(i*i, 1100000, i):
        is_prime[j] = False

small_prime = [p for p in range(1100) if is_prime[p]]
        
g = 0

for a in A:
    g = gcd(g, a)

if g != 1:
    print("not coprime")
    exit()

used = [False] * 1100000
primes = [a for a in A if is_prime[a]]
for p in primes:
    used[p] = True

not_primes = [a for a in A if not is_prime[a]]

for a in not_primes:
    for p in small_prime:
        if a == 1:break
        if a % p != 0:continue
        if used[p]:
            print("setwise coprime")
            exit()
        used[p] = True
        while a % p == 0:
            a //= p
    if a > 1:
        if used[a]:
            print("setwise coprime")
            exit()
        used[a] = True

print("pairwise coprime")




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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}
//-----------------------------------------
//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();

    ll h, n ;
    cin >> h >> n ;
    vll a(n) ;
    vll b(n) ;
    REP(i,n){
        cin >> a[i] >> b[i] ;
    }
    vll cost(h+1,LINF) ;
    cost[h] = 0 ;
    for(ll i=h;i>=1;i--){
        if(cost[i]==LINF){
            continue ;
        }
        for(int j=0;j<n;j++){
            int next = max((ll)0,i-a[j]) ;
            cost[next] = min(cost[next],cost[i]+b[j]) ;
        }
    }
    cout << cost[0] <<endl;


    


    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    

    return 0;
}

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

int main(){
  int a, b, k;
  cin >> a >> b >>k;
  int count = 0;
  for (int i = min(a, b); i > 0; i -= 1){
    if (a % i == 0 && b % i == 0){
      count ++;
      if (count == k){
        cout << i << endl;
        break;
      }
    }
  }
}

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

int gcd(int x, int y);

const int INF = 1001001001;

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/


int main() {
    string s;
    cin >> s;
    
    if (s[0] != 'A') {
        cout << "WA" << endl;
        return 0;
    }
    int num = 0;
    for (int i = 2; i <= s.size() - 2; i++) {
        if (s[i] == 'C')
            num++;
    }
    
    if (num == 0 || num >= 2) {
        cout << "WA" << endl;
        return 0;
    }

    rep(i, s.size()) {
        if (i == 0) continue;
        if (s[i] == 'C' && i >= 2 && i <= s.size() - 2) continue;
        if (s[i] >= 'A' && s[i] <= 'Z') {
            cout << "WA" << endl;
            return 0;
        }
    }

    cout << "AC" << endl;
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

Measured memory_bytes: 256
#!python3

# input
N, M = list(map(int, input().split()))


def main():
    if N == 1 and M == 1:
        ans = 1
    elif N == 1 or M == 1:
        ans = max(N, M) - 2
    else:
        ans = (N - 2) * (M - 2)
    
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
// 2014/06/26 Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	int cnt0 = 0;
	int cnt1 = 0;
	int cnt2 = 0;
	int cnt3 = 0;

	while(true){
		int a, b, c;
		cin >> a >> b >> c;

		if(a<b){
			swap(a, b);
		}
		if(a<c){
			swap(a, c);
		}

		if(a>=b+c){
			cout << cnt0 << ' ' << cnt1 << ' ' << cnt2 << ' ' << cnt3 << endl;
			break;
		}

		cnt0++;

		if(a*a==b*b+c*c){
			cnt1++;
		}
		else if(a*a<b*b+c*c){
			cnt2++;
		}
		else{
			cnt3++;
		}
	}

	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
int main()
{
  double n,d,i,x,y;
  int c=0;
  cin>>n>>d;
  for(i=0;i<n;i++)
  {
    cin>>x>>y;
    double ans=sqrt(pow(x,2)+pow(y,2));
    if(ans<=d)c++;
  }
  cout<<c<<endl;
  return 0;
}

Measured memory_bytes: 3836
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		boolean flag = false;
		for(int i = 1; i <= 9; i++){
			if(N % i == 0){
				if(N / i <= 9)flag = true;
			}
		}
		System.out.println((flag)? "Yes": "No");		
	}
}

Measured memory_bytes: 21972
let () = Scanf.scanf "%d %d %d\n" @@ fun n m q ->
  let abcds = Array.init q @@ fun _ ->
    Scanf.scanf "%d %d %d %d\n" @@ fun a b c d -> a, b, c, d in
  let ass =
    List.init n (Fun.const ())
    |> Fun.flip List.fold_left [(m, [])] (fun nass () ->
        List.concat @@
        Fun.flip List.map nass @@ fun (n, as_) ->
          List.init n @@ fun a -> (a + 1, a + 1 :: as_))
    |> List.map snd
    |> List.map Array.of_list in
  Printf.printf "%d\n" @@
  List.fold_left (fun m as_ ->
    max m @@
    Array.fold_right (fun (a, b, c, d) -> ( + ) @@
      if as_.(b - 1) - as_.(a - 1) = c then d else 0) abcds 0) min_int ass
  



Measured memory_bytes: 25348
#include <bits/stdc++.h>
#define dbg(x) cerr << #x << " = " << x << "\n"
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie()
using namespace std;
using ll = long long;

int main() {
    fast_io;

    int n, m, k;
    char c[10][10];

    cin >> n >> m >> k;
    for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j)
        cin >> c[i][j];

    int ans = 0;
    for (int msk_i = 0; msk_i < (1 << n); ++msk_i)
    for (int msk_j = 0; msk_j < (1 << m); ++msk_j) {
        int cnt = 0;
        for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j) {
            if ((msk_i & (1 << i)) || (msk_j & (1 << j)))
                continue;

            cnt += c[i][j] == '#';
        }
        ans += (cnt == k);
    }

    cout << ans << "\n";
}


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

using namespace std;

int main()
{
  array<string, 3> c;
  
  cin >> c[0] >> c[1] >> c[2];
  
  cout << c[0][0] << c[1][1] << c[2][2] << endl;
  
  return 0;
}

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


#define INF 1000000000000


signed main()
 {
   int n,m,x;
   cin>>n>>m>>x;
   int a[m];
   int syou=0,dai=0;
   rep(i,m){
     cin>>a[i];
     if(a[i]<x){syou++;}
     if(a[i]>x){dai++;}
   }
   cout<<min(syou,dai);


 }


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s; cin >> s;
    int q, rev = 0; cin >> q;
    stack<char> fq;
    queue<char> bq;
    while(q--) {
        int t; cin >> t;
        if(t == 1) {
            rev++;
        } else {
            int f; cin >> f;
            char c; cin >> c;
            if(f == 1) {
                if(rev%2 == 0) fq.push(c);
                else bq.push(c);
            } else {
                if(rev%2 == 0) bq.push(c);
                else fq.push(c);
            }
        }
    }
    string ans;
    while(!fq.empty()) { ans += fq.top(); fq.pop(); }
    ans += s;
    while(!bq.empty()) { ans += bq.front(); bq.pop(); }
    if(rev%2) reverse(ans.begin(), ans.end());
    cout << ans;
    return 0;
}

Measured memory_bytes: 1328
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL <<60;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}

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

ll choose2(ll n){
    return n*(n-1)/2;
}

int n,m,q;
int A[10];
int a[50],b[50],c[50],d[50];
ll ans = 0;

void dfs(int i,int val){
    if(i == n){
        ll tmp = 0;
        rep(k,0,q-1){
            if(A[b[k]-1] - A[a[k]-1] == c[k]) tmp += d[k];
        }
        ans = max(ans,tmp);
        return;
    }
    rep(j,val,m){
        A[i] = j;
        dfs(i+1,j);
    }
    return;
}

int main(){
    int n,m;
    cin>>n>>m;
    ll h[n];
    bool hoge[n];
    rep(i,0,n-1){
        cin>>h[i];
        hoge[i] = true;
    } 

    int a[m],b[m];

    rep(i,0,m-1){
        cin>>a[i]>>b[i];
    }

    rep(i,0,m-1){
        if(h[a[i]-1] >= h[b[i]-1]) hoge[b[i]-1] = false;
        if(h[a[i]-1] <= h[b[i]-1]) hoge[a[i]-1] = false;
    }

    rep(i,0,n-1){
        if(hoge[i]) ans++;
    }
    
    cout<<ans<<endl;
    return 0;
}

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

void main_()
{
    ll N;
    cin >> N;
    vector<ll> As;
    As.reserve(N);
    copy_n(istream_iterator<ll>(cin), N, back_inserter(As));

    sort(begin(As), end(As));

    ll sum = As[0];
    ll last = 0;

    for (ll i = 1; i < N; ++i) {
        if (sum * 2 < As[i]) {
            last = i;
        }
        sum += As[i];
    }

    ll ans = N - last;
    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
#define F first
#define S second
const int inf=1001001001; const long long INF=1001001001001001001;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
using priority_queue_small = priority_queue<int, vector<int>, greater<int> >;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};

string s;
int main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> s;
  if (s[0] == s[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 256
main = interact $ unlines . map (show . equal_sum_sets . map read . words) . init . lines

equal_sum_sets [n,k,s] = length [()| xs <- combBy k [1..n], sum xs == s]

combBy 0 _ = [[]]
combBy _ [] = []
combBy n (x:xs) = map (x:) (combBy (n-1) xs) ++ combBy n xs

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
while (x->left != NIL) { x = x->left;}
return x;
}
Node treeSearch(Node u, int k){
if (u == NIL || k == u->key) return u;
if(k < u->key) return treeSearch(u->left,k);
else return treeSearch(u->right,k);
}

Node treeSuccessor(Node x){
Node y;
if(x->right != NIL) return treeMinimum(x->right);
y = x->parent;
while (y != NIL && x == y->right)
{
x = y;
y = y->parent;
}
return y;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

while(x != NIL) {
y = x;
if(z->key < x->key) x = x->left;
else x = x->right;
}
z->parent = y;
if(y == NIL) root = z; //if T is empty
else if(z->key < y->key) y->left = z;
else y->right = z;
}

void inorder(Node u){
if(u != NIL)
{
inorder(u->left);
printf(" %d",u->key);
inorder(u->right);
}
}

void preorder(Node u){
if(u != NIL)
{
printf(" %d",u->key);
preorder(u->left);
preorder(u->right);
}
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
  }

  return 0;
}

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

int main() {

	int A, B;

	cin >> A >> B;

    if( A % 2 == 1 && B % 2 == 1 ) // AとBが奇数ならok
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 504
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<algorithm>
using namespace std;
int N, K;
int main() {
	cin >> N >> K;
	int a = 0, ans=0;
	for (int i = 0; i < N; ++i) {
		cin >> a;
		if (2 * a <= K) ans += 2 * a;
		else ans += 2 * (K - a);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
using namespace std;
static const int INF=(10<<9);
int main(){
    int n,t,s1,s2,ans=INF;
    vector<int> w;

    cin>>n;

    for(int i=0; i<n; i++){
        cin>>t;
        w.push_back(t);
    }
    for(int i=0; i<n; i++){
        s1=0,s2=0;
        for(int j=0; j<n; j++){
            if(j<=i){
                //cout<<"s1 : "<<w[j]<<endl;
                s1+=w[j];
            }else{
                //cout<<"s2 : "<<w[j]<<endl;
                s2+=w[j];
            }
        }


        if(abs(s1-s2)==0){
            cout<<0<<endl;
            return 0;
        }else if(ans>abs(s1-s2)){
            ans=abs(s1-s2);
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Iterator;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		HashMap<String,String> map = new HashMap<String,String>();
		for (int i = 0; i < line.length(); i++) {
			String s = String.valueOf(line.charAt(i));
			String a = map.get(s);
			if (a == null) {
				map.put(s, s);
			}
			else {
				map.put(s, a + s);
			}
		}
		String result = "Yes";
		Iterator<String> it = map.values().iterator();
		while (it.hasNext()) {
			String s = it.next();
			if (s.length() % 2 == 1) {
				result = "No";
				break;
			}
		}
		System.out.println(result);
	}
}


Measured memory_bytes: 8276
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;

int main(){
  ll n, h; cin >> n >> h;
  ll a[n+1], b[n+1];

  ll amax=-1;
  for(int i=1; i<=n; i++){
    cin >> a[i] >> b[i];
    amax = max(amax, a[i]);
  }

  sort(b+1, b+n+1);

  ll count = 0;
  for(int i=n; i>=1 && h>0 && b[i]>amax; i--){
    h -= b[i];
    count++;
  }

  //次に振り刀を振り続ける
  if(h>0)count += ceil((h*1.0)/(amax*1.0));

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <numeric>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600
#define long long long

int main(){
  int n,a,b;
  cin>>n>>a>>b;
  vector<long> vec(n);
  rep(i,n) cin>>vec[i];

  long ans=0;
  rep(i,n-1){
    if((vec[i+1]-vec[i])*a>b) ans+=b;
    else ans += (vec[i+1]-vec[i])*a;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(ll i=0;i<n;i++)
#define PRN(n) printf("%lld\n",n)
#define PRF(f) printf("%lf\n",f)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
typedef long long int ll;
int main(){
  ll n,sum=0,i=0;
  scanf("%lld",&n);
  while(sum<n){
    i++;
    sum+=i;
  }
  PRN(i);
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AOJ1_4_D
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');

            double a = double.Parse(str[0]);

            if (n > 1)
            {
                double b = double.Parse(str[1]);
                double BiggestOfAll = Math.Max(a, b);
                double SmallestOfAll = Math.Min(a, b);
                double AllInOne = a + b;
                for (int i = 1; i < n - 1; i++)
                {
                    b = double.Parse(str[i + 1]);
                    a = BiggestOfAll;
                    BiggestOfAll = Math.Max(a, b);
                }
                for (int i = 1; i < n - 1; i++)
                {
                    b = double.Parse(str[i + 1]);
                    a = SmallestOfAll;
                    SmallestOfAll = Math.Min(a, b);
                }
                for (int i = 1; i < n - 1; i++)
                {
                    b = double.Parse(str[i + 1]);
                    a = AllInOne;
                    AllInOne = a + b;
                }
                Console.WriteLine(SmallestOfAll + " " + BiggestOfAll + " " + AllInOne);
            }
            else if(n==1)
            {
                Console.WriteLine(a + " " + a + " " + a);
            }
        }
    }
}



Measured memory_bytes: 17900
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int dp[2];
    int n, p;
    cin >> n >> p;
    dp[0] = 1; dp[1] = 0;
    while (n--) {
        int x; cin >> x;
        x &= 1;
        if (x) {
            int t0 = dp[0];
            int t1 = dp[1];
            dp[0] += t1; dp[1] += t0;
        }
        else {
            dp[0] <<= 1;
            dp[1] <<= 1;
        }
    }
    cout << dp[p] << '\n';
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
 set <int> x;
int n;
int a[200005];
int m;
int main()
{   
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        if(!x.count(a[i]))
        {
            x.insert(a[i]);
        }
        else
        {
            printf("NO");
            return 0;
        }
        
    }
    printf("YES");
    return 0;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    char z;
    cin >>z;
    if('A'<=z&&z<='Z')cout<<'A'<<endl;
    else cout<<"a"<<endl;
}
    



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

int main() {
  int N , K , min=1 ;
  cin >> N >> K ;
  for (int i=0 ; i<N ; i++){
    if ( min < K )
      min *= 2 ;
    else
      min += K ;
  }
  cout << min << endl;
}

Measured memory_bytes: 256
/**
 *      author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *      created : 2019-11-30:23:33:59
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<typename T> inline void chmin(T &a, T b) { if (a > b) a = b; return; }
template<typename T> inline void chmax(T &a, T b) { if (a < b) a = b; return; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& vec) { os << '{'; for (size_t i = 0; i < vec.size(); ++i) { os << vec[i]; if (i != vec.size() - 1) os << ','; } os << '}'; return os; }
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int x, a; cin >> x >> a;
  if (x < a) {
    cout << 0 << endl;
  } else {
    cout << 10 << endl;
  }

  return 0;
}

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

int main(){
	int time;
    int time0count = 0;
	int remainder = 100;
	int sum = 0;
	for(int i = 0;i < 5;i++){
		cin >> time;
		if(remainder > time % 10 && time % 10 != 0){
			remainder = time % 10;
		}
		if(time % 10 == 0){
			sum += time;
            time0count++; 
		}else{
			sum += (time / 10 + 1) * 10;
		}
     // cout << remainder << endl;
	}
    if(time0count == 5){
       remainder = 10;
    }
	cout << sum - 10 + remainder << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<iomanip>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)

int retl(int K,int L){
    int tmp=0;
    while(pow(2,tmp) * L < K){
        tmp++;
    }
    return tmp;
}
int gcd(int a,int b)
{
	if (a%b==0)
	{
		return(b);
    }
	else
	{
		return(gcd(b,a%b));
    }
}
struct A{
    string s;
    int p;
    int order;
};

bool compare_by_b(pair<long, long> a, pair<long, long> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
    int N;
    cin>>N;
    int p[N];
    FOR(i,N){
        cin >>p[i];
    }
    int ans=0;
    for(int i=1;i<N-1;i++){
        if((p[i-1]<p[i]&&p[i]<p[i+1]) || (p[i-1]>p[i] && p[i]>p[i+1])){
            ans++;
        }
    }
    

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

Measured memory_bytes: 256
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per0(i, st, ed) for (int i = (st); i > ed; --i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
#define chmin(a, b) (a = a > b ? b : a)
#define chmax(a, b) (a = a < b ? b : a)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
#define int long long
int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}
const int maxn = 405;
int dp[maxn][maxn];
int a[maxn];
int s[maxn];
signed main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        #if __cplusplus >= 201103L
        auto start = steady_clock::now();
        #endif
    #endif
    int n = read();
    memset(dp, 0x3f, sizeof(dp));
    rep(i, 1, n) {
        a[i] = read();
        s[i] = a[i] + s[i - 1];
        dp[i][i] = 0;
    }
    for (int len = 2; len <= n; ++len) {
        for (int i = 1; i + len - 1 <= n; ++i) {
            int j = i + len - 1;
            for (int k = i; k < j; ++k) {
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] + s[j] - s[i - 1]);
            }
        }
    }
    cout << dp[1][n] << endl;
    #ifdef LOCAL
        #if __cplusplus >= 201103L
        auto end = steady_clock::now();
        duration<double> time_span = duration_cast<duration<double>>(end - start);;
        printf("Total time: %.6fs\n", time_span.count());
        #endif
    #endif
    return 0;
}

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

int main()
{
    long long N;
    cin >> N;
    vector<long long> P(N);
    for (long long i = 0; i < N; i++)
    {
        cin >> P[i];
    }
    long long ans = 0;
    long long mi = P[0];
    for (int i = 0; i < N; i++)
    {
        if (P[i] <= mi)
        {
            ans++;
            mi = min(mi, P[i]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace ABC117B
{
    public class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var N = ss.Next(int.Parse);
            var L = ss.Next(int.Parse, N).OrderByDescending(x => x).ToArray();
            sw.WriteLine(L[0] < L.Skip(1).Sum() ? "Yes" : "No");
            //---------------------------------
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }
}

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

typedef struct {
	int num;
	int ord;	
} A_order;


int compare_int(const void *a, const void *b) {
    return ((A_order*)b)->num - ((A_order*)a)->num;
}

int main() {
	int N;
	scanf("%d",&N);
	A_order A[N];
	for (int i = 0; i < N; i++) {
		scanf("%d",&A[i].num);
		A[i].ord = i;
	}
	qsort(A, N, sizeof(A_order), compare_int); // 降順
	for (int i = 0; i < N; i++) {
		if (i == A[0].ord) {
			printf("%d\n",A[1].num);
		}
		else printf("%d\n",A[0].num);
	}
	return 0;
}

Measured memory_bytes: 3324
n = int(input())
a,b,c = 0,0,0
for i in range(n):
  d,e,f = map(int,input().split())
  time = d-a
  kyori = (e-b)+(f-c)
  if time>=kyori and (time-kyori)%2==0:
     a,b,c = d,e,f
  else:
    print("No")
    break
else:
  print("Yes")

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

int main(){
  int x; cin >> x;
  int a[4];
  for (int i = 3; i >= 0; i--){
    a[i] = x % 10;
    x = x / 10;
  }
  char op[3];
  for (int i = 0; i < 8; i++){
    int sum = a[0];
    for (int j = 0; j < 3; j++){
      if (i & (1 << j)){
        op[j] = '+';
        sum += a[j + 1];
      }
      else{
        op[j] = '-';
        sum -= a[j + 1];
      }
    }
    if (sum == 7) break;
  }
  for (int j = 0; j < 3; j++) cout << a[j] << op[j];
  cout << a[3] << "=7" <<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 998244353;
const int INF = 9e18;

signed main() {
    int N, K;
    cin >> N >> K;
    vector<int> P(N);
    cin >> P;
    set<pair<int, int>> initCheck;
    vector<set<pair<int, int>>> check(N);
    {
        map<bool, int> temp;
        for (int i = 0; i + 1 < K; i++) temp[(P[i] < P[i + 1])]++;
        for (int i = 0; i + K - 1 < N; i++) {
            if (temp[false] == 0) initCheck.emplace(P[i], P[i + K - 1]);
            temp[(P[i] < P[i + 1])]--;
            if (i + K < N) temp[(P[i + K - 1] < P[i + K])]++;
        }
    }
    int ans = 0;
    set<int> sorting;
    for (int i = 0; i < K; i++) sorting.insert(P[i]);
    bool same = false;
    for (int i = 0; i + K - 1 < N; i++) {
        auto left = sorting.begin();
        auto right = sorting.end();
        right--;
        auto temp = make_pair(*left, *right);
        if (check[i].find(temp) == check[i].end()) {
            if (initCheck.find(temp) == initCheck.end()) ++ans;
            else {
                if (!same) {
                    ans++;
                    same = true;
                }
            }
        }
        if (i + K < N) {
            left++;
            check[i + 1].emplace(*left, P[i + K]);
        }
        sorting.erase(P[i]);
        if (i + K < N) sorting.insert(P[i + K]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 36224
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=998244353;

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

struct edge{
	int from,cost;
};

class RMQ{
	int n,seg,init;
	vector<int> dat;
public:
	RMQ(int siz,int def) : n(siz),init(def),seg(1){
		while(seg < n) seg *= 2;
		dat.resize(seg * 2 - 1);
		for(int i = 0;i < seg * 2 - 1;i++) dat[i] = init;
	}
	void update(int i,int x){
		i += seg - 1;
		dat[i] = x;
		while(i){
			i = (i - 1) / 2;
			dat[i] = min(dat[i * 2 + 1],dat[i * 2 + 2]); //do
		}
	}
	int get(int a = 0,int b = -1,int k = 0,int l = 0,int r = -1){
		if(b == -1) b = seg;
		if(r == -1) r = seg;
		if(b <= l || r <= a) return init;
		if(a <= l && r <= b) return dat[k];
		return min(get(a,b,k * 2 + 1,l,(l + r) / 2),get(a,b,k * 2 + 2,(l + r) / 2,r)); //do
	}
};

signed main(){
	int n,m;
	cin >> n >> m;
	vector<edge> G[100010];
	RMQ rmq(100010,INF);
	for(int i = 0;i < m;i++){
		int l,r,c;
		cin >> l >> r >> c; r--; l--;
		G[r].push_back({l,c});
	}
	rmq.update(0,0);
	for(int i = 1;i < n;i++){
		for(edge e : G[i]){
			rmq.update(i,min(rmq.get(i,i + 1),rmq.get(e.from,i) + e.cost));
		}
	}
	if(rmq.get(n - 1,n) != INF) cout << rmq.get(n - 1,n) << endl;
	else cout << -1 << endl;
}

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

#ifdef LOCAL
#include "../dump.hpp"
#else
#define dump(...)
#endif

using namespace std;

#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define pb push_back
#define fst first
#define snd second
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

int main(){
  int n,z,w; cin >> n >> z >> w;
  vi a(n); rep(i,n) cin >> a[i];

  if(n == 1) cout << abs(a[0] - w);
  else cout << max(abs(a[n-1]-w),abs(a[n-1]-a[n-2]));
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <math.h>
#include <algorithm>
#include <sstream>
#include <list>

using namespace std;

int main()
{
	int N;
	vector<int> H;

	cin >> N;

	int i, j;
	H.resize(N);

	int res = 0;
	bool flg;
	for (i = 0; i < N; i++)
	{
		cin >> H[i];
		flg = false;
		for (j = 0; j < i; j++)
		{
			if (H[j] <= H[i])
				continue;
			else
			{
				flg = true;
				break;
			}
		}

		if (!flg)
			res++;
	}

	printf("%d", res);
	 
	return 0;
}


Measured memory_bytes: 256