akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


pair<ll, ll> min_max(vector<ll>& a) {
    ll amin = LLONG_MAX, amax = LLONG_MIN;
    for (int i=a.size()-1; i>=0; --i) {
        amin = min(amin, a[i]);
        amax = max(amax, a[i]);
    }
    return make_pair(amin, amax);
}

ll solve(ll N, vector<ll>& a) {
    ll ans =0;
    while (true) {
        auto amm = min_max(a);
        ll amin = amm.first, amax = amm.second;
        if (amax <= N-1) break;

        ll s = 0;
        rep(i, N) {
            s += a[i] / N;
        }
        ans += s;
        rep(i, N) {
            ll q = a[i] / N;
            a[i] = a[i] - q*N + (s - q);
        }
    }
    return ans;
}

int main() {
    int N; cin >> N;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    cout << solve(N,a) << endl;
    return 0;
}


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

#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>

#include <algorithm>

using namespace std;



int main(int argc, char *argv[]) {


	int n, m;
	cin >> n >> m;
	int l = 1, r = n;
	for (int i = 0; i < m; i++) {
		int ll, rr;
		cin >> ll >> rr;
		l = max(l, ll);
		r = min(r, rr);
	}
	if (r < l)
		cout << 0 << endl;
	else
		cout << r - l + 1 << endl;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    scanf("%2d%2d",&a,&b);
    int flag=0;
    int flag1=0;
    int dum=0;
    int num=0;
    if(a<=12&&a>=1)flag=1;
    if(a>12||a==0)flag1=1;
    if(b<=12&&b>=1)dum=1;
    if(b>12||b==0)num=1;
    if(flag==1&&dum==1)
        printf("AMBIGUOUS\n");
    else if(flag1==1&&num==1)
        printf("NA\n");
    else if(flag1==1)
        printf("YYMM\n");
    else
        printf("MMYY\n");
    return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::max;

fn main() {
    let stdin = std::io::stdin();
    let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
    let mut next = move || -> String{
        bytes
            .by_ref()
            .map(|r|r.unwrap() as char)
            .skip_while(|c|c.is_whitespace())
            .take_while(|c|!c.is_whitespace())
            .collect()
    };
    input! {next,
        n: usize,
        a: [usize; n],
    }
    let mut a: Vec<_> = a.into_iter().enumerate().map(|(i,v)| (v,i)).collect();
    a.sort();
    a.reverse();
    // dbg!(&a);
    // dp[i][j] is the best result after using i numbers and filling j on the left ((i-j) on the right)
    let mut dp = vec![vec![0; n+1]; n+1];
    for (i, (activity, old_i)) in a.into_iter().enumerate() {
        dp[i+1][0] = dp[i][0] + (((n-1-(i-0)) as i64) - old_i as i64).abs() as usize * activity;
        for left in 1..=i+1 {
            // dbg!(i, left, (n-1-(i+1-left)));
            dp[i+1][left] = max(
                if i >= left {
                    dp[i][left] + (((n-(i+1-left)) as i64) - old_i as i64).abs() as usize * activity
                } else {
                    0
                },
                dp[i][left-1] + (((left-1) as i64) - old_i as i64).abs() as usize * activity
            );
            // dbg!(dp[i][left] + (((n-1-(i+1-left)) as i64) - old_i as i64).abs() as usize * activity);
            // dbg!(dp[i][left-1] + (((left-1) as i64) - old_i as i64).abs() as usize * activity);
            // dbg!(dp[i+1][left]);
        }
        // println!("{:?}", &dp[i+1]);
    }
    println!("{}", dp[n].iter().max().unwrap());
}


Measured memory_bytes: 33484
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>

#include<deque>
#define pi 3.141592653589793238
#include<chrono>

#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define f0 get<0>
#define f1 get<1>
#define f2 get<2>
#define db double
using namespace std;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    //cin >> T;
    while (T--) {
        ll n;
        cin >> n;
        vector<ll> v(n);
        for(i = 0; i < n; i++){
            cin >> v[i];
            if(v[i] == 0){
                cout << 0;
                return 0;
            }
        }
       ll MAX = 1e18;
       ll p = 1;
       
       for(i = 0 ; i < n; i++){
           if(v[i] <= MAX / p){
               p *= v[i];
           }
           else{
               cout << -1;
               return 0;
           }
       }
       cout << p;
    }
    
    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  set<int> st;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    st.insert(a);
  }
  cout << ((int)st.size() == N ? "YES" : "NO") << '\n';
  return 0;
}


Measured memory_bytes: 9600
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>

using namespace std;
typedef long long ll;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)

const int MAX_N = 100;
int N, D, X, A[MAX_N];

void solve() {
    int ans = 0;
    REP(i, N) ans += (D - 1) / A[i] + 1;
    cout << ans + X << endl;
}

int main() {
    cin >> N >> D >> X;
    REP(i, N) cin >> A[i];
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll H, W, A, B;
  cin >> H >> W >> A >> B;
  vector<vector<ll>> ans(H, vector<ll>(W, 1));
  for (ll i = 0; i < B; ++i) {
    for (ll j = 0; j < W; ++j) {
      ans.at(i).at(j) = (ans.at(i).at(j) + 1) % 2;
    }
  }
  for (ll i = 0; i < H; ++i) {
    for (ll j = 0; j < A; ++j) {
      ans.at(i).at(j) = (ans.at(i).at(j) + 1) % 2;
    }
  }
  for (ll i = 0; i < H; ++i) {
    for (ll j = 0; j < W; ++j) {
      cout << ans.at(i).at(j);
    }
    cout << endl;
  }
}


Measured memory_bytes: 9088
import sys, re
from math import ceil, floor, sqrt, pi, factorial#, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    n = i_input()
    num_list = []
    for _ in range(n):
        x, l = i_map()
        left = x - l
        right = x + l
        tmp = [right, left]
        num_list.append(tmp)

    num_list.sort()

    ans = 0
    max_right = -INF

    for i in range(n):
        right, left = num_list[i]
        if max_right <= left:
            ans += 1
            max_right = right

    print(ans)

if __name__ == '__main__':
    main()


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

int main() {
    int n, maxv = -1, maxv1 = -1, memo, maxi;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];

        
        maxv = max(maxv, a[i]);
        if (maxv != memo)
        {
            maxi = i;
        }
        
        memo = maxv;

    }

    for (int i = 0; i < n; i++)
    {
        if (maxi != i)
        {
            cout << maxv << endl;
        }
        
        if (maxi == i)
        {
            for (int j = 0; j < n; j++)
            {
                if (i == j)
                {
                    continue;
                }
                maxv1 = max(maxv1, a[j]);
            }
            cout << maxv1 << endl;
        }
        
    }
    
}

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

string c;

int main(){
  int s,e;

  cin >> c;

  for(int i=0;i<c.size();i++){
    if(c[i]=='A'){
      s=i;
      break;
    }
  }

  for(int i=c.size()-1;i>=0;i--){
    if(c[i]=='Z'){
      e=i+1;
      break;
    }
  }

  printf("%d\n",e-s);

  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  if (a < b) {
    printf("a < b\n");
  } else if (a > b) {
    printf("a > b\n");
  } else {
    printf("a == b\n");
  }
}



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

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
using vb = vector<bool> ;
using pll = pair<ll, ll> ;

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;


void pre(){

    

}


void solve(){

    ll n;
    cin >> n;
    string s;
    cin >> s;
    int i=0 , j=n-1;
    int ans=0;
    while(i<j){
        while(i<n  and s[i] == 'R')i++;
        while(j>=0 and s[j] == 'W')j--;
        if(i < j){
            swap(s[i],s[j]);
            i++,j--;
            ans++;
        }
    }   
    cout << ans;

}


int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

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

int main(){
  int64_t H, W;
  cin >> H >> W;
  int64_t N = H*W;
  int64_t ans;

  if(H == 1 || W == 1){
    ans = 1;
  }else if(N%2 == 0){
    ans = N/2;
  }else if(N%2 == 1){
    ans = (N+1)/2;
  }
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace::std;
#define all(x) (x).begin(),(x).end()
#define endl '\n'
#define int long long
#define TT template <class T>

TT istream& operator>>(istream &I, pair<T,T>& p) {return I >> p.first >> p.second;}
TT ostream& operator<<(ostream &O, pair<T,T>& p) {return O << p.first << ' ' << p.second;}
TT istream& operator>>(istream &I, vector<T>& v) {for (T &e: v) I >> e; return I;}
TT ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



void solve() {
        double r; cin >> r;
        cout << M_PI * r * 2;
}


signed main() { //[J][O][L][S][K][E][Y]
        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int t = 1;
//        cin >> t;
        while (t--) solve();
        return 0;
}

/*

*/

Measured memory_bytes: 3788
#include<iostream>
#include<cstdio>
#include<cmath>

using namespace std;

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

int main() {
  double a, b, c, d, e, f;
  while (cin >> a >> b >> c >> d >> e >> f) {
    double x = (c * e - b * f) / (a * e - b * d);
    double y = (c * d - a * f) / (b * d - a * e);
    if (-0.0005 <= x && x < 0.0005) x = 0;
    if (-0.0005 <= y && y < 0.0005) y = 0;
    printf("%.3f %.3f\n", x, y);
  }
  return 0;
}

Measured memory_bytes: 1236
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	string s; cin >> s;
    if(s.back() != 's') {
        cout << s + "s" << endl;
    } else {
        cout << s + "es" << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long
//vector<int> g1;
//g1.push_back(i);

using namespace std;

int main()
{
	string n;
	cin >> n;
	if (n[2]==n[3]&&n[4]==n[5]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    string  s,pre="kkkk",h=""; cin >> s ; 
    int ans=0;
    int  n=sz(s);
    for (int i=0;i<n;i++){
        h += s[i]; 
        if (h != pre) ans++, pre=h, h=""; 
    }
    if (sz(h) and pre != h) ans++;
    cout <<ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3740
// Gaurav Aggarwal

/*
useful stl
array<ll,size> ar;         //size(),front(),back(),fill(),empty()
deque<ll> d                //push_back(),push_front(),pop_front(),pop_back()
vector<ll> v(size,val);    //push_back(),*max_element(v.begin(),v.end()),accumulate(v.begin(),v.end(),0)
stack<ll> g;               //push(),pop(),top(),size(),empty()         LIFO
queue<ll> q;               //push(),size(),front(),back(),empty()      FIFO
priority_queue<ll> pq
*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> ipair;
typedef pair<long,long> lpair;
typedef pair<double,double> pdd;
#define scan(x) do{while((x=getchar_unlocked())<'0'); for(x-='0'; '0'<=(_=getchar_unlocked()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define mod 1000000007
#define PI 3.141592653589793238462643383279502884 
#define debug1(a) cout<<a<<"\n";
#define debug2(a,b) cout<<a<<" "<<b<<"\n";
#define debug3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define debug_arr(a,n) {for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}}
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define beg_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {a[i] = 0;}

ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod; 
    } 
    return res%mod; 
}


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

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

    int a,b;
    cin>>a>>b;
    int maxi = max(a,b);
    int mini = min(a,b);

    int one = maxi;
    maxi -= 1;

    one += max(maxi, mini);

    cout<<one;


    return 0;
}

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

int main() {
    ll N, M;
    cin >> N >> M;
    ll ans = 0;
    ans += min(N, M/2);
    N -= ans;
    M -= ans*2;
    while(M >= 4) {
        M -= 4;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top, N[1000];

void push(int);
int pop(void);

int main(){
  int x,y;
  char n[100];
  top = 0;

  while(scanf("%s", n) != EOF){
    if(n[0] == '+'){
      x = pop();
      y = pop();
      push(x + y);
    }
    else if(n[0] == '-'){
      y = pop();
      x = pop();
      push(x - y);
    }
    else if(n[0] == '*'){
      x = pop();
      y = pop();
      push(x * y);
    }
    else{
      push(atoi(n));
    }
  }

  printf("%d\n", pop());

  return 0;
}


void push(int x){
  N[++top] = x;
}

int pop(){
  top--;
  return N[top + 1];
}



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

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int main(){
    ll x, y;
    cin >> x >> y;
    if(abs(x-y)<=1){
        cout << "Brown" << endl;
    }else{
        cout << "Alice" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using ll = long long int;
using namespace std;

int main(){
    int n; cin >> n;
    vector<vector<int>> field(n, vector<int>(n, 0));
    bool no_black = true;
    for(int i=0; i<n; i++){
        string line; cin >> line;
        for(int j=0; j<n; j++){
            if(line[j] == '#'){
                field[i][j] = 1;
                no_black = false;
            }
            else{field[i][j] = 0;}
        }
    }
    if(no_black){
        cout << -1 << endl;
        return 0;
    }
    vector<int> blackcol(n,0);
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(field[j][i] == 1){
                blackcol[i]++;
            }
        }
    }
    // Check rows
    vector<int> whiterow(n,0);
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(field[i][j] == 0){
                whiterow[i]++;
            }
        }
        if(blackcol[i] == 0){
            whiterow[i]++;
        }
    }
    // for(auto& v:whiterow){
    //     cout << v << " ";
    // }
    // cout << endl;
    int ans = *min_element(whiterow.begin(), whiterow.end()); 
    for(int i=0; i<n; i++){
        if(blackcol[i] != n){
            ans += 1;
        }
    }
    cout << ans << endl;
    return 0;
}


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

namespace ABC_042_A___和風いろはちゃんイージー
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] inputs = Console.ReadLine().Split(' ');

            int counter5 = 0;
            int counter7 = 0;
            string output = "NO";

            foreach (string input in inputs)
            {
                if (input.Equals("5"))
                {
                    counter5++;
                }

                if (input.Equals("7"))
                {
                    counter7++;
                }
            }

            if (IsShichigocho(counter5, counter7))
            {
                output = "YES";
            }

            Console.WriteLine(output);

        }

        static bool IsShichigocho(int counter5, int counter7)
        {
            bool res = false;
            if (counter5 == 2
                && counter7 == 1)
            {
                res = true;
            }


            return res;
        }
    }
}


Measured memory_bytes: 11092
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.IArray           as IA
import qualified Data.Array.IO               as AI
import qualified Data.Array.MArray           as MA
import qualified Data.Array.ST               as STA
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import qualified Data.Graph                  as G
import           Data.Int
import qualified Data.IntMap                 as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence               as SQ
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Tree                   as T
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

class Printable a where
  format :: a -> String

instance Printable Int where
  format = show

instance Printable Integer where
  format = show

instance Printable Double where
  format = show

instance Printable Float where
  format = show

instance Printable Char where
  format = show

instance Printable String where
  format x = x

instance Printable Bool where
  format = show

put :: Printable a => a -> IO ()
put = putStr . format

putLn :: Printable a => a -> IO ()
putLn = putStrLn . format

putList :: Printable a => [a] -> IO ()
putList [a] = put a
putList (a:as) = do
  put a
  putStr " "
  putList as

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

main = do
  [a, b] <- readInt
  put $ (a - 1) * (b - 1)


Measured memory_bytes: 380
// abc154_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#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 REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    string S, T;
    cin >> S >> T;
    int A, B;
    cin >> A >> B;
    string U;
    cin >> U;
    if (S == U){
        print(A-1, B);
    } else {
        print(A, B-1);
    }


    return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
  int n;
  while(cin >> n, n) {
    int max_score = 0;
    int min_score = 1000;
    int s;
    int m = 0;
    for (int i = 0; i < n; i++) {
      cin >> s;
      m += s;
      max_score = max(max_score, s);
      min_score = min(min_score, s);
    }
    cout << (m - max_score - min_score) / (n - 2) << endl;
  }
}

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

int main() {
    int k,a,b;
    cin>>k>>a>>b;
  int flag=0;
  int i=a;
  while(i<=b){
      if(i%k==0){
          flag=1;
      }
      i++;
  }
   if(flag==1){
       cout<<"OK"<<endl;
   }
   else {
       cout<<"NG"<<endl;
   }
   
	return 0;
}



Measured memory_bytes: 3568
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define all(v) (v).begin(),v.end()
#define fi first
#define se second
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
map<char,int> mp;
int main(){
int n,m;
cin>>n;
vector<ll> a(n),b(n);
ll ans=0,cnt=0;
for(int i=0;i<n;i++)cin>>a[i];
for(int i=0;i<n;i++){
    if(a[i]==0){ans+=cnt;cnt=0;}
    cnt+=a[i]/2;a[i]%=2;
    if(i+1<n&&a[i]==1&&a[i+1]!=0){a[i+1]--;cnt++;}
}
cout<<ans+cnt<<endl;
}


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

const int N = 2e6;

int a[N];

int main() {
	clog << "Ready\n";
	
	int n;
	cin >> n;
	
	for (int i = 1; i <= n; ++ i)
		cin >> a[i];
	
	int cnt = 0;
	
	for (int i = 1; i <= n; ++ i) {
		if (i == 1 or i == n)
			continue;
		vector <int> temp(3);
		#define eb emplace_back
		temp.eb(a[i]);
		temp.eb(a[i - 1]);
		temp.eb(a[i + 1]);
		#define all(x) x.begin(), x.end()
		sort(all(temp), greater<int> ());
		cnt += (temp[1] == a[i]);
	}
	cout << cnt;
	
	return 0;
}


Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;

int main(){
    fastio
    string s ; 
    cin >> s ;
    if ( s[0] == s[1] || s[1] == s[2] || s[2] == s[3] ){
    	cout << "Bad" << endl;
    }
    else cout << "Good" << endl;
    return 0 ;
}


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

int main(){
  int N;
  cin >> N;
  int max=0, midx=1;
  for(int i=2; i<=N; i++){
    int num = i;
    int count=0;
    while(1){
      if(num%2==0){
        num/=2; count++;
      }
      else break;
    }
    if(max<count){
      max = count;
      midx = i;
    }
  }
  cout << midx << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;


int main(){
    int a,b;
    cin>>a>>b;
    if(a>=b)cout<<a+max(a-1,b)<<endl;
    else cout<<b+max(a,b-1)<<endl;
    
    
    
    
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<P> ab(M);
  REP(i, M) {
    int x, y;
    cin >> x >> y;
    ab[i] = P(x, y);
  }
  set<int> S;
  REP(i, M) {
    if(ab[i].first == 1) { S.insert(ab[i].second); }
  }
  bool ok = false;
  REP(i, M) {
    if(ab[i].second == N) {
      if(S.count(ab[i].first)) { ok = true; }
    }
  }
  if(ok) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}

Measured memory_bytes: 8064
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val N = nextInt()
    val L = nextIntList().sorted()
    var ans = 0L
    for (i in 0 until N) {
        for (j in i + 1 until N - 1) {
            val k = L.bfind(L[i] + L[j], j + 1)
            if (k < 0) continue
            ans += k - j
        }
    }
    println(ans)
}

tailrec fun List<Int>.bfind(v: Int, l: Int = 0, r: Int = this.size): Int {
    if (r - l == 1) {
        return if (v <= this[l]) -1 else l
    }
    val m = (l + r) / 2
    val vm = this[m]
    return when {
        vm < v -> bfind(v, m, r)
        else -> bfind(v, l, m)
    }
}

Measured memory_bytes: 40944
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,k;
  cin>>a>>b>>k;
  if(b-a+1<=2*k){
    for(int i=a;i<=b;i++){
      cout<<i<<endl;
    }
  }
 else{
   for(int i=a;i<a+k;i++){
     cout<<i<<endl;
   }
  for(int i=b-k+1;i<b+1;i++){
    cout<<i<<endl;
  }
 }
}

Measured memory_bytes: 256
class UnionFind():
  def __init__(self, N):
    self.par = [i for i in range(N)]
 
  def root(self, x):
    if self.par[x] == x:
      return x
    else:
      self.par[x] = self.root(self.par[x])
      return self.par[x]
  
  def unite(self, x, y):
    self.par[self.root(y)] = self.root(x)
    
  def same(self, x, y):
    return self.root(x) == self.root(y)

N, M = map(int, input().split())
p = list(map(int, input().split()))
uf = UnionFind(N)

for i in range(M):
  x, y = map(int, input().split())
  uf.unite(x-1, y-1)
  
r = 0
for i in range(N):
  r += uf.same(i, p[i] - 1)
print(r)


Measured memory_bytes: 127724
#pragma comment(linker, "/STACK:33554432")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <iterator>
#include <stack>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <cstring>
#include <bitset>
#include <math.h>

using namespace std;

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

const int MAXN = 2e3 + 20;

void solve() {

    ll h, n;
    cin >> h >> n;

    ll s = 0;

    for (int i = 0;i < n; ++ i){
        ll currc;
        cin >> currc;
        s += currc;
    }

    if (s >= h)
        cout << "Yes";
    else
        cout << "No";

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);

    solve();
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (H, W) = readLine()!!.split(" ").map(String::toInt)
    var HW = Array(H) { readLine()!!.toCharArray() }.toList()
    HW = HW.filterNot { it.all { it == '.' } }
    val remove = mutableListOf<Int>()
    for (i in 0 until W) {
        var all = true
        for (j in HW.indices) {
            val cell = HW[j][i]
            if (cell == '#') {
                all =false
            }
        }
        if(all){
            remove.add(i)
        }
    }

    for (i in 0 until HW.size){
        for(j in 0 until HW[0].size){
            if(remove.contains(j)){
                continue
            }
            print(HW[i][j])
        }
        println()
    }

}

Measured memory_bytes: 40336
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;

int dp[4][100005]; //0 = r, 1 = s, 2 = p
map<char, int> m;
map<int, char> mp;

bool win(int n1, int n2){
	char c1 = mp[n1], c2 = mp[n2];

	if(c1 == 'r' && c2 == 'p') return true;
	else if(c1 == 's' && c2 == 'r') return true;
	else if(c1 == 'p' && c2 == 's') return true;
	return false; 
}
 
signed main()
{
    tezz
    
    int n, k, r, s, p;
    cin>>n>>k>>r>>s>>p;

    string str;
    cin>>str;

   	m['r'] = 0, m['s'] = 1, m['p'] = 2;
   	mp[0] = 'r', mp[1] = 's', mp[2] = 'p';


    // for(int j=0;j<n;j++){
    // 	for(int i=0;i<3;i++){
    // 		if(win(m[s[j]], i) && j<k){
    // 			if(mp[i] == 'r') dp[i][j+1] = dp[i][j+1] + max({dp[0][j], dp[1][j], dp[2][j]});
    // 			else if(mp[i] == 's') dp[i][j+1] = dp[i][j+1] + max({dp[0][j], dp[1][j], dp[2][j]});
    // 			else if(mp[i] == 'p') dp[i][j+1] = dp[i][j+1] + max({dp[0][j], dp[1][j], dp[2][j]});
    // 		}
    // 		else if(win(m[s[j]], i)){
    // 			if(mp[i] == 'r'){
    // 				if(max({dp[0][j-k], dp[1][j-k], dp[2][j-k]}) == dp[0][j-k]){
    // 					dp[i][j+1] = dp[i][j+1] + max({dp[0][j], dp[1][j], dp[2][j]});
    // 				}
    // 			}
    // 			else if(mp[i] == 's') dp[i][j+1] = dp[i][j+1] + max({dp[0][j], dp[1][j], dp[2][j]});
    // 			else if(mp[i] == 'p') dp[i][j+1] = dp[i][j+1] + max({dp[0][j], dp[1][j], dp[2][j]});
    // 		}
    // 	}
    // }

   	int ans = 0, winner[n+1];
   	memset(winner, -1, sizeof(winner));

    for(int i=0;i<k;i++){
    	if(str[i] == 'r'){
    		winner[i] = 2;
    		ans += p;
    	}
    	else if(str[i] == 's'){
    		winner[i] = 0;
    		ans += r;
    	}
    	else{
    		winner[i] = 1;
    		ans += s;
    	}
    }
    // cout<<ans<<endl;

    for(int i=k;i<n;i++){
    	if(str[i] == 'r'){
    		if(winner[i-k] != 2){
    			ans += p;
    			winner[i] = 2;
    		}
    		else winner[i] = -1;
    	}
    	else if(str[i] == 's'){
    		if(winner[i-k] != 0){
    			ans += r;
    			winner[i] = 0;
    		}
 			else winner[i] = -1;
    	}
    	else{
    		if(winner[i-k] != 1){
    			ans += s;
    			winner[i] = 1;
    		}
    		else winner[i] = -1;
    	}
    }

    cout<<ans;
} 

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

#define int long long
#define endl "\n"
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);


main(){
	FIO
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    if(a==0){
    	cout<<1;
    }
    if(b==0){
    	cout<<2;
    }
    if(c==0){
    	cout<<3;
    }
    if(d==0){
    	cout<<4;
    }
    if(e==0){
    	cout<<5;
    }
}


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

int main()
{
    int n;
    cin >> n;
    vector<int64_t> a(n), b(n);
    for (auto &i : a)
    {
        cin >> i;
    }
    for (auto &i : b)
    {
        cin >> i;
    }
    int64_t ans = 0;
    for (int k = 0; k <= 28; k++)
    {
        vector<int64_t> c(a), d(b);
        int64_t t = 1ll << k, num = 0;
        for (int i = 0; i < n; i++)
        {
            c[i] %= (1ll << (k + 1));
            d[i] %= (1ll << (k + 1));
        }
        sort(d.begin(), d.end());
        for (auto &i : c)
        {
            num += distance(d.begin(), lower_bound(d.begin(), d.end(), 2 * t - i));
            num -= distance(d.begin(), lower_bound(d.begin(), d.end(), t - i));
            num += distance(d.begin(), lower_bound(d.begin(), d.end(), 4 * t - i));
            num -= distance(d.begin(), lower_bound(d.begin(), d.end(), 3 * t - i));
        }
        if (num & 1)
        {
            ans += t;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6548
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int val[3][n];
    for(int i=0;i<n;i++){
        cin>>val[0][i]>>val[1][i]>>val[2][i];
    }
    int dp[3][n];
    dp[0][0]=val[0][0];
    dp[1][0]=val[1][0];
    dp[2][0]=val[2][0];
    for(int i=1;i<n;i++){
        dp[0][i]=max(dp[1][i-1]+val[0][i],dp[2][i-1]+val[0][i]);
        dp[1][i]=max(dp[0][i-1]+val[1][i],dp[2][i-1]+val[1][i]);
        dp[2][i]=max(dp[1][i-1]+val[2][i],dp[0][i-1]+val[2][i]);
    }
    cout<<max({dp[0][n-1],dp[1][n-1],dp[2][n-1]})<<endl;
}



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

int main(){
    int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k; cin >> k;
    cout << a[k-1] << endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
    char a, b, c, d;
    scanf("%c%c%c%c", &a, &b, &c, &d);
    if (a == b && c == d && a != c) {
        printf("Yes\n");
        return 0;
    }
    if (a == c && b == d && a != b) {
        printf("Yes\n");
        return 0;
    }
    if (a == d && b == c && a != b) {
        printf("Yes\n");
        return 0;
    }

    printf("No\n");

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Edge{
	bool operator<(const struct Edge &arg) const{
		if(s != arg.s){
			return s < arg.s;
		}else{
			return t < arg.t;
		}
	}
	int s,t;
};

struct Info{
	Info(int arg_to,int arg_edge_id){
		to = arg_to;
		edge_id = arg_edge_id;
	}
	int to,edge_id;
};

int V,E,number;
int order[100000],lowlink[100000];
bool visited[100000];
Edge edge[100000];
vector<Info> G[100000];

void recursive(int node_id){

	order[node_id] = number++;
	lowlink[node_id] = order[node_id];

	int next_node;

	for(int i = 0; i < G[node_id].size(); i++){

		next_node = G[node_id][i].to;

		if(order[next_node] == -1){

			visited[G[node_id][i].edge_id] = true;
			recursive(next_node);
			lowlink[node_id] = min(lowlink[node_id],lowlink[next_node]);

		}else if(visited[G[node_id][i].edge_id] == false){

			lowlink[node_id] = min(lowlink[node_id],order[next_node]);
		}
	}
}

int main(){

	scanf("%d %d",&V,&E);

	for(int i = 0; i < E; i++){
		scanf("%d %d",&edge[i].s,&edge[i].t);
		if(edge[i].s > edge[i].t){
			swap(edge[i].s,edge[i].t);
		}
		G[edge[i].s].push_back(Info(edge[i].t,i));
		G[edge[i].t].push_back(Info(edge[i].s,i));
	}

	sort(edge,edge+E);

	number = 0;

	for(int i = 0; i < V; i++){
		order[i] = -1;
		lowlink[i] = -1;
	}

	for(int i = 0; i < E; i++){
		visited[i] = false;
	}

	recursive(0);

	int from,to;

	for(int i = 0; i < E; i++){

		from = edge[i].s;
		to = edge[i].t;

		if(order[edge[i].s] > order[edge[i].t]){
			swap(from,to);
		}

		if(order[from] < lowlink[to]){
			printf("%d %d\n",edge[i].s,edge[i].t);
		}
	}

	return 0;
}



Measured memory_bytes: 7652
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

// Popされる順番に注意。
// 減算、除算のときは後からPopした値を前にしないとおかしくなる

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	formula := strings.Split(sc.Text(), " ")
	stack := NewStack()
	for _, v := range formula {
		switch v {
		case "+":
			a, _ := stack.Pop()
			b, _ := stack.Pop()
			stack.Push(b + a)
		case "-":
			a, _ := stack.Pop()
			b, _ := stack.Pop()
			stack.Push(b - a)
		case "*":
			a, _ := stack.Pop()
			b, _ := stack.Pop()
			stack.Push(b * a)
		default:
			num, _ := strconv.Atoi(v)
			stack.Push(num)
		}
	}
	ans, _ := stack.Pop()
	fmt.Println(ans)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}

// Stackは[]intのエイリアス
type Stack []int

// Push adds an element
func (s *Stack) Push(v int) {
	*s = append(*s, v)
}

// Pop removes the top element and return it
func (s *Stack) Pop() (int, error) {
	if s.Empty() {
		return 0, fmt.Errorf("stack is empty")
	}

	v := (*s)[len(*s)-1]
	*s = (*s)[:len(*s)-1]
	return v, nil
}

// Peek returns the top value
func (s *Stack) Peek() (int, error) {
	if s.Empty() {
		return 0, fmt.Errorf("stack is empty")
	}

	return (*s)[len(*s)-1], nil
}

// Size returns the length of stack
func (s *Stack) Size() int {
	return len(*s)
}

// Empty returns true when stack is empty
func (s *Stack) Empty() bool {
	return s.Size() == 0
}

// NewStack generates stack
func NewStack() *Stack {
	s := new(Stack)
	return s
}



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

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main(){
	LL a, b, c;
	cin >> a >> b >> c;
	LL d=c-a-b;
	if(d<0) cout << "No" << endl;
	else if(4*a*b<d*d) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

const int MAXN = 300010;
int n, K, A[MAXN];
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> K >> n;
	if (K % 2 == 0) {
		std::cout << K / 2;
		for (int i = 2; i <= n; ++i) std::cout << ' ' << K;
	} else {
		for (int i = 1; i <= n; ++i) A[i] = K + 1 >> 1;
		int cur = n;
		for (int i = n / 2; i; --i) {
			if (A[cur] == 1) --cur;
			else {
				--A[cur];
				for (int j = cur + 1; j <= n; ++j) A[j] = K;
				cur = n;
			}
		}
		for (int i = 1; i <= cur; ++i) std::cout << A[i] << ' ';
	}
	return 0;
}


Measured memory_bytes: 3456
# T の末尾に dream dreamer erase eraser のいずれかを追加する。

s = gets.chomp
len = s.size
(len - 1).downto(0) do |j|
  if aaa = s[j..-1].match(/dreamer|dream|eraser|erase/)
    s[j, aaa.to_s.size] = ""
  end
end

puts s == "" ? "YES" : "NO"

Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll N, x;
    cin >> N >> x;
    vector<ll> a(N);
    for (auto& in : a)
        cin >> in;
    ll ans = 0;
    for (int i = 1; i < N; i++) {
        if (a[i] > x) {
            ans += a[i] - x;
            a[i] = x;
        }
        if (a[i - 1] > x) {
            ans += a[i - 1] - x;
            a[i - 1] = x;
        }
        ll tmp = a[i] + a[i - 1];
        if (tmp > x) {
            ans += tmp - x;
            a[i] -= tmp - x;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024