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

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

int32_t main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);

	int n, k;
	cin >> n >> k;

	string s;
	cin >> s;

	if (n == 1) {
		cout << "0\n";
		return 0;
	}

	int cnt = (s[0] == 'R' and s[1] == 'R') + (s[n - 2] == 'L' and s[n - 1] == 'L');
	for (int i = 1; i + 1 < n; i++) {
		if (s[i] == 'L' and s[i - 1] == 'L') cnt++;
		if (s[i] == 'R' and s[i + 1] == 'R') cnt++;
	}

	cout << min(cnt + 2 * k, n - 1) << "\n";
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
    string str;
    cin>>str;
    for(int i=0;i<str.length()-1;i++)
    {
        if(str[i]==str[i+1])
        {
            cout<<"Bad"<<endl;
            return 0;
        }
    }
    cout<<"Good"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <string.h>
using namespace std;

#define HUNDRED 100
#define THOUSAND 10000
#define TENTHOUSAND 10000
#define HUNDREDTHOUSAND 100000

int main() {
	int n;
	int fx =0;
	int temp;

	cin >> n;

	temp = n;

	while(temp > 0){
		fx += (temp % 10);
		temp /= 10;
	}

	if((n % fx) == 0){
		cout << "Yes";
	}
	else{
		cout << "No";
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << " = " << x << ".\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define print(xx) cout << (xx) << endl
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
const int INF = ((1LL << 30) + (1LL << 29));
const ll MOD = 1000000007;

/* 
*/

//=================================================
int N,A,B;

//=================================================
void input()
{
    cin>>N>>A>>B;
}

//=================================================
void solve()
{
    if (A == B || N==2) {
        cout<<1<<endl;
    }
    else if (A > B || N==1) {
        cout<<0<<endl;
    }
    else {
        
        int a = (N-2) * (B-A) + 1;
        cout<<a<<endl;
    }
}

//=================================================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define forn(i, n) for (ll i = 0; i < (n); i++)
#define fori(i, b, e) for (ll i = (b); i < (e); i++)
#define forr(i, b, e) for (ll i = (b); i >= (e); i--)
#define allele(v) v.begin(), v.end()
#define fi first
#define se second
#define Mat vector<vector<ll>>
#define Arr vector<ll>

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, k;
    cin >> n >> k;
    ll MAX = (n - 1) * (n - 2) / 2;
    if(k > MAX) return cout << -1, 0;
    cout << (MAX - k + n - 1) << endl;
    fori(i, 2, n + 1) cout << 1 << ' ' << i << endl;

    ll a = 2, b = 3;
    forn(i, MAX - k)
    {
        cout << a << ' ' << b << endl;
        b++;
        if(b > n) a++, b = a + 1;
    }
    return 0;
}

Measured memory_bytes: 256
program abc110b
  implicit none
  integer n, m, x, y
  integer, dimension(:), allocatable :: xs, ys

  read *, n, m, x, y
  allocate(xs(n + 1), ys(m + 1))
  read *, xs(1:n), ys(1:m)
  xs(n + 1) = x
  ys(m + 1) = y
  if (maxval(xs) < minval(ys)) then
     print '(a)', "No War"
  else
     print '(a)', "War"
  end if
  deallocate(xs, ys)
end program abc110b


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
using namespace std;
#define l long long
#define pb push_back
#define mem(a,n) memset(a,n,sizeof(a))
#define find(v,n) find(v.begin(),v.end(),n)
#define sort1(v) sort(v.begin(),v.end())
#define lb(v,n) lower_bound(v.begin(),v.end(),n)-v.begin()
#define ub(v,n) upper_bound(v.begin(),v.end(),n)-v.begin()
#define mod 1000000007
#define reverse(s) reverse(s.begin(),s.end())
//#define pi pair<l,l> 
const double pi=3.141592653589793;
bool isprime(l n)
{
	for(l i=2;i*i<=n;i++)
	{
		if(n%i==0)
			return false;
	}
	return true;
}
/*bool fact(l n)
{
	vector<l> v;
	for(l i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			if(i%2==1||(n/i)%2==1)
			{
				return true;
			}
		}
	}
	return false;
}*/
l power(l a,l b)
{
	l ans=1;
	while(b>0)
	{
		if(b&1)
		{
			ans=(ans*a);
		}
		b>>=1;
		a=(a*a);
	}
	return ans;
}//prefixsums
void frooty()
{
	l n;
	cin>>n;
	if(n%1000==0)
	{
		cout<<0<<"\n";
		return ;
	}
	else
	{
		l d=n/1000;
		cout<<(d+1)*1000-n<<"\n";
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int q=1;
//	cin>>q;
	while(q--)
	{
		frooty();
	}
}

Measured memory_bytes: 3616
#include<iostream>

using namespace std;

int main() {
  string s,t;
  cin>>s>>t;
  int ans=t.size(), s1=s.size(), t1=t.size(), x, i, j;
  for(i=0; i<=s1-t1; i++) {
  	x=0;
  	for(j=0; j<t1; j++)
  	  if(s[i+j]!=t[j]) x++;
  	if(x<ans) ans=x;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3140
[N,Q] = list(map(int,input().split()))
S = input()
LR = []
for i in range(Q):
    LR.append(list(map(int,input().split())))

T = [0]*N
U = [0]*N
cnt = 0
for i in range(N-1):
    if S[i]+S[i+1]=="AC":
        T[i+1]=1
        cnt+=1
    U[i+1] = cnt

for i in range(Q):
    L = LR[i][0]-1
    R = LR[i][1]-1
    print(U[R]-U[L])

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


void solve(long long A, long long B, long long C, long long X){
    ll cnt = 0;
    for(ll i=0; i<=A; i++){
        for(ll j=0; j<= B; j++){
            for(ll k=0; k<= C; k++){
                if(i*500+j*100+k*50 == X) cnt ++;
            }
        }
    }
    cout << cnt<< endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long X;
    scanf("%lld",&X);
    solve(A, B, C, X);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <time.h>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}


struct UnionFind {
	vector<int> par, rank, cnt;
	UnionFind(int n) : par(n), rank(n, 0), cnt(n, 1){
		for(int i=0; i<n; ++i) par[i] = i;
	}
 
	int find(int x) {
		if (x == par[x]) return x;
		return par[x] = find(par[x]);
	}
 
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
 
		if (rank[x] < rank[y]) swap(x, y);
 
		par[y] = x;
		cnt[x] += cnt[y];
		if (rank[x] == rank[y]) rank[x]++;
	}
 
	bool same(int x, int y) {
		return find(x) == find(y);
	}
 
	int size(int x) {
		return cnt[find(x)];
	}
};


int main(){
    long long N,M; cin >> N >> M;
    vector<pair<long long,long long> > p(N);
    for (int i = 0; i < N; i++){
        cin >> p[i].first >> p[i].second;
    }
    long long sum = 0;
    sort(p.begin(),p.end());
    for (int i = 0; i < N; i++){
        if (p[i].second < M){
            M -= p[i].second;
            sum += p[i].first * p[i].second;
        } else {
            sum += p[i].first * M;
            M = 0;
        }
        if (M == 0) break;
    }
    cout << sum<< endl;
}

Measured memory_bytes: 1792
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
A3 = list(map(int,input().split()))
n = int(input())
b = [int(input()) for _ in range(n)]
B1 = [0,0,0] 
B2 = [0,0,0]
B3 = [0,0,0]

for i in b:
    if i in A1:
        x = A1.index(i)
        B1[x] = 1
    if i in A2:
        x = A2.index(i)
        B2[x] = 1
    if i in A3:
        x = A3.index(i)
        B3[x] = 1

if B1[0] == B1[1] == B1[2] == 1 or B2[0] == B2[1] == B2[2] == 1 or B3[0] == B3[1] == B3[2] == 1:
    print("Yes")
    exit()
elif B1[0] == B2[0] == B3[0] == 1 or B1[1] == B2[1] == B3[1] == 1 or B1[2] == B2[2] == B3[2] == 1 or B1[0] == B2[1] == B3[2] == 1 or B1[2] == B2[1] == B3[0] == 1:
    print("Yes")
    exit()
else:
    print("No")







Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
int main()
{
  int n;
  cin>>n;
  set<string> s;
  for(int i=0;i<n;i++)
  {
  	string g;
  	cin>>g;
  	s.insert(g);
  }
  cout<<s.size();
}
			
		

Measured memory_bytes: 19256
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
 
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
 
 int N,M;
 int A[111111];
 
signed main(){
    cin>>N>>M;
    rep(i,N)cin>>A[i];
    
    priority_queue<int>que;
    rep(i,N)que.push(A[i]);
    while(M--){
        int v=que.top();
        que.pop();
        v>>=1;
        que.push(v);
    }
    
    int ans=0;
    while(que.size()){
        ans+=que.top();
        que.pop();
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2168
function f()
    input = map(x -> parse(Int, x), split(chomp(readline()), " "))
    B = map(x -> parse(Int, x), split(chomp(readline()), " "))

    N = input[1]
    #M = input[2]
    C = input[3]
    
    ret = 0
    for i in 1:N
        a = map(x -> parse(Int, x), split(chomp(readline()), " "))
        if sum(a .* B) + C > 0
            ret += 1
        end
    end
    print(ret)
end
f()

Measured memory_bytes: 118612
import java.util.*;
import java.text.*;


public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int oddNumbers = 0, a = 0;

		int input = sc.nextInt();

		for(int i = 1; i <= input; i++)
		{
			a += 1;
			if(a % 2 == 1)
			{
				oddNumbers += 1;
			}
		}

		double probability = (double)oddNumbers / a;
		System.out.println(probability);
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
/*
void chmin(ll a, ll b){if (a>b){a = b; return true;}return false;}
void chmax(ll a, ll b){if (a<b){a = b; return true;}return false;}
*/

const ll MOD = 1000000007;
const ll INF = 9999999999;

bool check(int n,vector<vector<int>> &say,vector<int> &honest){
  for (int i=0; i<n; i++){
    if (honest[i] == 0) continue;
    for (int j=0; j<n; j++){ 
      if (say[i][j] == -1) continue;
      if (say[i][j] != honest[j]) return false;
    }
  }
  return true;
}

void solve(int n,int indi, vector<vector<int>> &say, vector<int> &honest,
          int &ans){
  if (n==indi) return;
  int buf = 0;
  for (int i=0; i<n; i++){
    buf += honest[i];
  }
  if (check(n,say,honest)){
    ans = max(ans,buf);
  }
  solve(n,indi+1,say,honest,ans);
  honest.at(indi) = 0;
  if (check(n,say,honest)){
    ans = max(ans,buf-1);
  }
  solve(n,indi+1,say,honest,ans);
  honest.at(indi) = 1;
  return;
}

int main() {
  int n; cin >>n;
  vector<int> a(n);
  vector<vector<int>> say(n, vector<int>(n, -1));
  // i行目にAi-1の証言、i行j列目にjが正直物なら1、不親切なら0,
  // 情報なしなら-1を格納
  for (int i=0; i<n; i++){
    cin >>a.at(i);
    for (int j=0; j<a.at(i); j++){
      int x,y; cin >>x >>y;
      x--;
      say.at(i).at(x) = y;
    }
  }
  vector<int> honest(n,1);
  int ans = 0;
  solve(n,0,say,honest,ans);

  cout <<ans <<endl;

}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000
#define SE 2000000000

typedef struct C {
  char suit;
  int value;
} Card;

Card L[MAX/2+2], R[MAX/2+2];

void merge(Card A[], int left, int mid, int right){
  int i, j, k, n1, n2;
  
  n1 = mid - left;
  n2 = right - mid;
  for( i = 0 ; i < n1 ; i++ ){
    L[i] = A[left+i];
  }
  for( i = 0 ; i < n2 ; i++ ){
    R[i] = A[mid+i];
  }
  L[n1].value = R[n2].value = SE;
  i = j = 0;
  for( k = left ; k < right ; k++ ){
    if( L[i].value <= R[j].value ){
      A[k] = L[i];
      i = i +1;
    }
    else {
      A[k] = R[j];
      j = j + 1;
    }
  }

}

void mergeSort(Card A[], int left, int right){
  int mid;
  if( left + 1 < right ){
    mid = ( left + right ) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int partition(Card A[], int p, int r){
  int i, j;
  Card x, t;
  x = A[r];
  i = p-1;
  for( j = p ; j < r ; j++ ){
    if( A[j].value <= x.value ){
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }
  t = A[i+1];
  A[i+1] = A[r];
  A[r] = t;
  return i + 1;
}

void quickSort(Card A[], int p, int r){
  int q;
  if( p < r ){
    q = partition(A, p, r);
    quickSort(A, p, q-1);
    quickSort(A, q+1, r);
  }
}

int main(){
  int n, i, v;
  Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);

  for( i = 0 ; i < n ; i++ ){
    scanf("%s %d", S, &v);
    A[i].suit = B[i].suit = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A, 0, n);
  quickSort(B, 0, n-1);

  for( i = 0 ; i < n ; i++ ){
    if( A[i].suit != B[i].suit ) stable = 0;
  }

  if( stable == 1 ) printf("Stable\n");
  else printf("Not stable\n");
  for( i = 0 ; i < n ; i++ ){
    printf("%c %d\n", B[i].suit, B[i].value);
  }

  return 0;
}



Measured memory_bytes: 4036
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    string s; cin >> s;
    ll q; cin >> q;
    bool rev = false;
    string head = "";
    string tail = "";
    REP(i, q) {
        ll t; cin >> t;
        if (t == 1) {
            rev = !rev;
        } else {
            ll f;
            char c;
            cin >> f >> c;

            if (f == 1) {
                if (rev) {
                    tail += c;
                } else {
                    head += c;
                }
            } else {
                if (rev) {
                    head += c;
                } else {
                    tail += c;
                }
            }
        }
    }
    if (rev) {
        reverse(tail.begin(), tail.end());
        reverse(s.begin(), s.end());
        cout << tail << s << head << endl;
    } else {
        reverse(head.begin(), head.end());
        cout << head << s << tail << endl;
    }
    return 0;
}

Measured memory_bytes: 3932
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

ll N;

/*
    
    dp1[n] : [0..n] の内、i==nで操作をしていない場合の ΣBの最大値
    dp2[n] : [0..n] の内、i==nで操作をしている場合の   ΣBの最大値
    
    
*/

ll dp1[100005];
ll dp2[100005];

int main(){
	cin >> N;
	
	vector<ll> A(N+1);
	for ( int i = 0; i < N; i++ )
		cin >> A[i];
	
	dp1[0] = A[0];
	dp2[0] = -A[0];
	for ( int i = 1; i < N; i++ ){
		dp1[i] = max(dp1[i-1]+A[i], dp2[i-1]-A[i]);
		dp2[i] = max(dp1[i-1]-A[i], dp2[i-1]+A[i]);
	}
	
	cout << dp1[N-1] << endl;
	
	return 0;
}



Measured memory_bytes: 2560
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int n, m;
vi p;

class UnionFind{
    public:
        UnionFind(int n){
            par.resize(n); rnk.resize(n);
            for(int i = 0; i < n; i++){ par[i] = i; rnk[i] = 0; }
        }
        int find(int x) {
            if(par[x] == x) return x;
            else return par[x] = find(par[x]);
        }
        void unite(int x, int y) {
            x = find(x); y = find(y);
            if(x == y) return;

            if(rnk[x] < rnk[y]) { par[x] = y; }
            else{
                par[y] = x;
                if (rnk[x] == rnk[y]) rnk[x]++;
            }
        }
        bool same(int x, int y) { return find(x) == find(y); }

    private:
        vector<int> par; vector<int> rnk;
};


int main()
{
    cin >> n >> m;
    p.resize(n); rep(i, n) cin >> p[i];
    rep(i, n) p[i]--;

    UnionFind un(n);
    rep(i, m){
        int x, y; cin >> x >> y;
        un.unite(x - 1, y - 1);
    }
    int ans = 0;
    rep(i, n){
        if(p[i] == i || un.same(p[i], i)) ans++;
    }
    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	Solver() {
		ios::sync_with_stdio( false );
		cout << fixed << setprecision( 10 );
	}

	void solve() {
		int N, M;
		cin >> N >> M;

		vector<int> A( N );
		int sum = 0;
		for( auto& v: A ) {
			cin >> v;
			sum += v;
		}

		int pop = 0;
		for( int i = 0; i < N; ++i ) {
			if( A[i]*4*M >= sum ) {
				pop += 1;
			}
		}

		cout << (pop >= M ? "Yes" : "No") << endl;
	}
};

int main() {
	Solver().solve();
	return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
MOD = 10 ** 9 + 7
a = [int(input()) for _ in range(M)]
DP = [1] * (N + 1)
for idx in a:
    DP[idx] = 0

if N >= 2:
    for i in range(2, N+1):
        if DP[i] != 0:
            if DP[i - 1] != 0:
                if DP[i - 2] != 0:
                    DP[i] = DP[i - 1] + DP[i - 2]
                else:
                    DP[i] = DP[i - 1]
            else:
                if DP[i - 2] != 0:
                    DP[i] = DP[i - 2]
                else:
                    DP[i] = 0

print(DP[N]%MOD)


Measured memory_bytes: 460020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int gcd(int a, int b) {  
  return b != 0 ? gcd(b, a % b) : a;
}//MAX
int lcm(int a, int b) { 
   return a * b / gcd(a, b);
   }
//MIN

 

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  int i=0;
  int ans=0;
  while(i<N){
    if(A[i] == A[i+1]){
      i++;
      continue;
    }
    ans++;
    if(A[i] < A[i+1]){
      while(A[i] <= A[i+1]){
        i++;
      }
    }else{
      while(A[i] >= A[i+1]){
        i++;
      }
    }
    i++;
  }
  cout << ans << endl;
  return 0;
}

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

#define mod 1000000007
#define LOCAL 0
#define pb push_back
#define ll long long

ll po(ll a,ll b){
	ll x = 1,y=a;
	while(b>0){
		if(b%2){
			x = x*y;
			x %= mod;
		}
		y=y*y;
		y%=mod;
		b/=2;
	}
	return x;
}

int main(){
	if(LOCAL){
    	freopen("C:/Users/gold/Desktop/sublime IO/input.txt","r",stdin);
    	freopen("C:/Users/gold/Desktop/sublime IO/output.txt","w",stdout);
	}
	int T = 1;
	//scanf("%d",&T);
	while(T--){
		int a,b,c,d;
		scanf("%d %d %d %d",&a,&b,&c,&d);
		int ans = min(b,d) - max(a,c);
		ans = max(0,ans);
		printf("%d\n",ans);
	}
	return 0;	
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-

def solve():
    S = input()

    ans = 0
    i = 0
    while i != len(S):
        if i+1 >= len(S):
            break

        if S[i] != S[i+1]:
            # 消す
            if i == 0:
                if len(S) <= 2:
                    ans += 1
                    S = ""
                    continue
                else:
                    ans += 1
                    S = S[2:]
                    continue
            else:
                if i+2 < len(S):
                    ans += 1
                    S = S[:i] + S[i+2:]
                    i -= 1
                    continue
                else:
                    ans += 1
                    S = S[:i]
                    i -= 1
                    continue
            
        i += 1
    print(ans*2)


if __name__ == "__main__":
    solve()
    

Measured memory_bytes: 3452
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);

    int n = scan.nextInt();

    if (n >= 10) {
      if (n >= 100) {
        if (n >= 1000) {
          if (n >= 10000) {
            if (n == 100000) {
              System.out.println(90909);
            } else {
              System.out.println(n - 9090);
            }
          } else {
            System.out.println(909);
          }
        } else {
          System.out.println(n - 90);
        }
      } else {
        System.out.println(9);
      }
    } else {
      System.out.println(n);
    }
  }

}

Measured memory_bytes: 23252
#include<iostream>

using namespace std;

int main()
{
	int n,k;
	long long int*a;
	int temp=1;
	cin>>n; 
	k=n/2;
	a = new long long int[n];
	if(n-2*k)
	{
		for(int i=0;i<n;i++){
			
			if(temp==1)
			{
				cin>>a[k];
				temp++;
			}
			else 
			{
				if(temp%2==1)
					cin>>a[k-temp/2];
				else
					cin>>a[k+temp/2];
				temp++;
			}
		}
 	}
 	else
 	{
 		for(int i=0;i<n;i++){
			
			if(temp==1)
			{
				cin>>a[k];
				temp++;
			}
			else 
			{
				if(temp%2==0)
					cin>>a[k-temp/2];
				else
					cin>>a[k+temp/2];
				temp++;
			}
		}
	 }
	 for(int i=0;i<n;i++)
	 	cout<<a[i]<<' ';
	return 0;
 }
  

Measured memory_bytes: 3712
#include<stdio.h>
#include <iostream>
using namespace std;
int main()
{
	int a,sum=0,n,m;
	scanf("%d%d",&n,&m);
	for(int i=n;i<=m;i++)
	{
	int b,c,d,e,f;
	b=i%10;
	c=i/10%10;
	d=i/100%10;
	e=i/1000%10;
	f=i/10000%10;
	if(b==f&&c==e)sum++;
	
  }
  printf("%d",sum);
	return 0;
}

Measured memory_bytes: 256
using namespace std;
#include<bits/stdc++.h>
#define ll long long int
const int m=1e9;
int main(){
  int z=m;
  int h,w,k;
  cin>>h>>w>>k;
  vector<string>s(h);
  for(int i=0;i<h;i++)
    cin>>s[i];
  int pos=1<<(h-1);
  vector<int>store[w];
  for(int i=0;i<pos;i++){
    int ca=__builtin_popcount(i);
    int sum;
    for(int j=0;j<w;j++){
      sum=0;
      for(int k=0;k<h;k++){
        sum+=(s[k][j]&1);
        if((i>>k)&1){
          store[j].push_back(sum);
          sum=0;
        }
      }
      store[j].push_back(sum);
      for(int x:store[j]){
        if(x>k)
          ca=m;
      }
    }
    vector<int>ans(store[0].size());
    for(int j=0;j<w;j++){
      bool ok=0;
      for(int l=0;l<ans.size();l++){
          ok|=(ans[l]+store[j][l]>k);
      }
      if(ok){
        ca++;
        ans=vector<int>(ans.size());
      }
      for(int l=0;l<ans.size();l++)
        ans[l]+=store[j][l];
      store[j].clear();
    }
    z=min(ca,z);
  }
  cout<<z;
  return 0;
}


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

using namespace std;
typedef long long ll;

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

  int ans = 0;
  for (int i = 0; i + 1 < n; i++) {
    ans++;
    if (s[i] == 'x' && s[i + 1] == 'x') break;
    if (i + 1 == n - 1) ans++;
  }
  cout << (n == 1 ? 1 : ans) << endl;

  return 0;
}


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

#define ten(n) ((int)1e##n)
// dump macro{{{
// http://www.creativ.xyz/dump-cpp-652
#define DUMPOUT cerr // 変数ダンプ先。coutかcerr

#ifdef PCM
// 引数はいくつでもどんな型でも可（ストリーム出力演算子があればOK）
#define dump(...) DUMPOUT<<"  "; \
  DUMPOUT<<#__VA_ARGS__; \
  DUMPOUT<<":=> "; \
  dump_func(__VA_ARGS__); DUMPOUT<<"in ["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl;
#define dump_1d(x,n) DUMPOUT <<"  " \
  <<#x<<"["<<#n<<"]"<<":=> {"; \
  rep(i,n){ DUMPOUT << x[i] << (((i)==(n-1))?"}":", "); } DUMPOUT <<" in [" << __LINE__ << "]" << endl;

#define dump_2d(x,n,m) DUMPOUT <<"  " \
    <<#x<<"["<<#n<<"]"<<"["<<#m<<"]"<<":=> \n"; \
    rep(i,n)rep(j,m){ DUMPOUT << ((j==0)?"     |":" ") << x[i][j] << (((j)==(m-1))?"|\n":" "); } \
    DUMPOUT <<"  in [" << __LINE__ << "]" << endl;
#else
#define dump(...) 42
#define dump_1d(...) 42
#define dump_2d(...) 42
#endif

// デバッグ用変数ダンプ関数
void dump_func() {
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&&... tail)
{
    DUMPOUT << head;
    if (sizeof...(Tail) == 0) {
        DUMPOUT << " ";
    }
    else {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}

// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
    os << "{";
    for (int i = 0; i<vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}/*}}}*/

#define rep(i, x) for(int i = 0; i < (int)(x); i++)/*{{{*/
#define reps(i,x) for(int i = 1; i <= (int)(x); i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define foreach(x,a) for(auto& (x) : (a) )
#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define INF 2147483647
#define INFLL 1000000000000000000LL
#define MOD 1000000007/*}}}*/

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;/*{{{*/
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<vii> vvii;
typedef tuple<int,int,int> iii;
typedef set<int> si;
typedef complex<double> pnt;
typedef vector<pnt> vpnt;
typedef priority_queue<pii,vii,greater<pii> > spq;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*}}}*/

// global variables

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

  if (abs(n-m)>=2){
    cout << 0 << endl;
    return 0;
  }

  ll res = 1;
  reps(i, n){
    res *= i;
    res %= MOD;
  }
  reps(i, m){
    res *= i;
    res %= MOD;
  }

  if (abs(n-m)==1){
    cout << res << endl;
  }
  else{
    cout << (res*2)%MOD << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef int64_t Int;
#define dump(x) cout << (x) << '\n'
Int mod = 1e9+7;

int main() {
    Int n;
    cin >> n;
    vector<Int> a(n);
    Int res = 0;
    Int cnt = 0;
    Int mi = 1e9;
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
        res += abs(a[i]);
        mi = min(mi, abs(a[i]));
        if (a[i] < 0) cnt++;
    }
    dump(cnt % 2 == 0 ? res : res - mi * 2);
    return 0;
}

Measured memory_bytes: 1024
import sys
input=sys.stdin.readline
n,q=map(int,input().split())
l=[]
for i in range(n-1):
  l.append(list(map(int,input().split())))
l2=[]
for i in range(q):
  l2.append(list(map(int,input().split())))
connection=[]
for i in range(n):
  connection.append([])
for i in range(n-1):
  connection[l[i][0]-1].append(l[i][1]-1)
 
L4=[]
for i in range(n):
  L4.append(0)
for i in range(q):
  L4[l2[i][0]-1]+=l2[i][1]
distance=[]
for i in range(n):
  distance.append(0)
distance[0]=L4[0]

L=[0]
L2=[]
L3=[]
while len(L2)!=n and len(L)!=0:
  for j in range(len(L)):
    for k in range(len(connection[L[j]])):
      distance[connection[L[j]][k]]=distance[L[j]]+L4[connection[L[j]][k]]
      L3.append(connection[L[j]][k])
    L2.append(L[j])
  L=L3
  L3=[]
for i in range(len(distance)):
  distance[i]=str(distance[i])
print(' '.join(distance))

Measured memory_bytes: 147420
#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 m, k;
	cin >> m >> k;
	if (k > pow(2, m) - 1) {
		cout << -1 << endl;
		return 0;
	}

	if (m == 1) {
		if (k == 0)
			cout << "1 1 0 0" << endl;
		else
			cout << -1 << endl;
		return 0;
	}

	for (int i = 0; i <= pow(2, m) - 1; i++)
		if (i != k)
			cout << i << " ";
	cout << k << " ";
	for (int i = pow(2, m) - 1; i >= 0; i--)
		if (i != k)
			cout << i << " ";
	cout << k << endl;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define lnt long long int
int main()
{
   lnt n;
   cin>>n;
   lnt d[n];
   for(int i=0;i<n;i++)
   {

       cin>>d[i];
   }

   lnt beg=0,last=1000000000;
   lnt mid = (beg+last)/2;
   while(beg<=last)
   {
       //cout<<mid<<endl;
       lnt arr[n]={0};
       lnt val = d[n-1]-mid;
       lnt prev=mid;
       for(int i=0;i<n-1;i++)
       {
           prev = d[i]-prev;

       }
       if(prev==val)
       {

           break;
       }
       if(val>prev)
       {
           beg=mid+1;
       }
       else
       {

           last=mid-1;
       }
       mid=(beg+last)/2;

   }
   cout<<2*mid<<" ";
   lnt prev=mid;
   for(int i=0;i<n-1;i++)
   {
       prev = d[i]-prev;
       cout<<2*prev<<" ";

   }





}


Measured memory_bytes: 2816
N = int(input())
P_list = [int(e) for e in input().split()]

min_P = P_list[0]
ans = 0

for i in P_list:
  #print(i)
  
  if min_P >=i:
    #print("#")
    ans += 1
    min_P = i
    
print(ans)

Measured memory_bytes: 25768
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long int ll;
typedef unsigned long long ull;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<ll,ll> P;


int main()
{
    int n,k;
    cin>>n >>k;
    vector<int>a(n);
    vector<int>tasu(n);
    vector<int>h(n);
    
    rep(i,n)
    {
        cin>>a[i];
        tasu[i]=0;
        h[i]=0;
    }
    if(n<=k){
        rep(i,n)cout<<n<<" ";
        cout<<endl;
        return 0;
    }
    rep(t,k)
    {   
        tasu=h; 
        rep(i,n)
        {
            tasu[max(0,i-a[i])]++;
            int tasuin=i+a[i]+1;
            if(tasuin<n)tasu[tasuin]--;
        }
        ll now=0;
        bool finish=true;
        rep(i,n-1)
        {
            tasu[i+1]+=tasu[i];
        }
        if(tasu==a)break;
        a=tasu;
    }
    rep(i,n)cout<<a[i]<<" ";
    cout<<endl;
    return 0;

}

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

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

int main() {
    long long x;
    cin >> x;
    long long sum = x / 11 * 2;
    int res = x % 11;
    if(res > 6){
        sum += 2;
    }else if (res > 0){
        sum += 1;
    }

    cout << sum;

    return 0;
}

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

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

    if (s[0] == 'R') {
        if (s[1] == 'R') {
            if (s[2] == 'R') {
                cout << 3 << endl;
            }
            else {
                cout << 2 << endl;
            }
        }
        else if (s[2] == 'R') {
            cout << 1 << endl;
        }
        else {
            cout << 1 << endl;
        }
    }
    else if (s[1] == 'R') {
        if (s[2] == 'R') {
            cout << 2 << endl;
        }
        else {
            cout << 1 << endl;
        }
    }
    else if (s[2] == 'R') {
        cout << 1 << endl;
    }
    else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
const int SIZEN = 300010;
LL C[SIZEN] = {0};
LL D[SIZEN] = {0};
LL ans[SIZEN] = {0};
int N;
int main(){
    scanf("%d",&N);
    for(int i = 1;i <= N;i++){
        int x;scanf("%d",&x);
        C[x]++;
    }
    for(int i = 1;i <= N;i++){
        D[C[i]]++;
    }
    for(int i = 1;i <= N;i++)D[i] += D[i-1];
    LL g = 0;
    memset(ans,-1,sizeof ans);
    ans[N+1] = 0;
    for(int i = 1;i <= N;i++){
        g = g + (D[i]-D[i-1]) * i;
      //  printf("g = %d , D[%d] = %d\n",g,i,D[i]);
        ans[(g + (D[N] - D[i] )*i)/i ] = i;
    }
    for(int i = N;i >= 1;i--){
        if(ans[i] == -1)ans[i] = ans[i+1];
        else continue;
    }
    for(int i = 1;i <= N;i++)printf("%d\n",ans[i]);printf("\n");
    getchar();getchar(); 
    return 0;

}

Measured memory_bytes: 8700
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


def comb(n, k):
    if n < 0 or n < k or k < 0:
        return 0
    return fac[n] * ifac[k] * ifac[n - k] % mod


n, k = map(int, read().split())
mod = 10 ** 9 + 7
max_n = 2 * 10 ** 5 + 1
ans = 0
fac = [1] * max_n
inv = [1] * max_n
ifac = [1] * max_n
for i in range(2, max_n):
    fac[i] = fac[i - 1] * i % mod
    inv[i] = mod - inv[mod % i] * (mod // i) % mod
    ifac[i] = ifac[i - 1] * inv[i] % mod

for i in range(min(n, k) + 1):
    ans += comb(n, i) * comb(n - 1, i)
    ans %= mod
print(ans)


Measured memory_bytes: 26740
#include <bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;



int main() {
  int N;
  cin >> N;
  ll sum = 0, m = INF;
  ll cnt = 0;
  for (int i = 0; i < N; i++) {
    ll a;
    cin >> a;
    if(a<0)
      cnt++;
    a = abs(a);
    sum += a;
    m = min(a, m);
  }
  if(cnt%2==0){
    cout << sum << endl;
    return 0;
  }
  cout << (sum - m*2) << endl;

  return 0;
}


Measured memory_bytes: 256
def solve():
	h,w,a,b = map(int, input().split())
	mx = max(h,w)
	mod = 10**9+7
	fac = [1]*(h+w+1)
	for i in range(1,h+w+1):
		fac[i] = fac[i-1]*i%mod
	inv = [1]*(mx+1)
	inv[-1] = pow(fac[mx], mod-2, mod)
	for i in range(mx-1, -1, -1):
		inv[i] = inv[i+1]*(i+1)%mod
	const = inv[h-a-1]*inv[a-1]%mod
	ans = sum(fac[h-a+i-1]*inv[i]*fac[a+w-2-i]*inv[w-i-1]%mod for i in range(b,w))
	print(ans*const%mod)

if __name__=="__main__":solve()


Measured memory_bytes: 14836
hp,sp = input().split(" ")
hp = int(hp)
sp = int(sp)
attack = input().split(" ")
damage = 0

for i, new in enumerate(attack):
    attack[i] = int(attack[i])

for i in range(0,sp):
    damage += attack[i]

if damage >= hp:
    print("Yes")

else:
    print("No")

Measured memory_bytes: 16476
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    string s, t;
    cin >> s >> t;

    if(s.size() < t.size()) { 
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    int idx = -1;
    for(int i = 0; i <= s.size() - t.size(); i++) {
        int cnt = 0;

        for(int j = 0; j < t.size(); j++) {
            if(s[i+j] == t[j] || s[i+j] == '?') {
                cnt++;
            }
        }

        if(cnt == t.size()) {
            idx = i;
        }
    }
    if(idx == -1) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    
    for(int i = 0; i < t.size(); i++) {
        s[idx+i] = t[i];
    }
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == '?') {
            s[i] = 'a';
        }
    }
    
    cout << s << endl;
    return 0;
}

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

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
int main(){
  int n, ans=0;
  cin >> n;
  for(int i = 1; i <= n; i++){
    ans+=i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
from collections import Counter

H,W,N = map(int, raw_input().split())

squares = defaultdict(lambda: 0)
for i in range(N):
    a,b = map(lambda x: x-1, map(int, raw_input().split()))
    for j in range(max(0,a-2), min(H-2,a+1)):
        for k in range(max(0,b-2), min(W-2,b+1)):
            squares[(j,k)] += 1

counter = Counter(squares.values())
s = sum(counter.values())
print (H-2)*(W-2) - s #not colored
for i in range(1,10):
    print counter[i]


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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define MAXR 100000
#define _GLIBCXX_DEBUG

int threemax(int a, int b, int c) {
	if (a >= b && a >= c) {
		return a;
	}
	else if (b >= a && b >= c) {
		return b;
	}
	else {
		return c;
	}
}

int threemin(int a, int b, int c) {
	if (a <= b && a <= c) {
		return a;
	}
	else if (b <= a && b <= c) {
		return b;
	}
	else {
		return c;
	}
}

void chmaxl(ll &a,ll b){
	if(a<b){
		a=b;
	}
	return;
}

void chminl(ll &a,ll b){
	if(a>b){
		a=b;
	}
	return;
}

void chmaxi(int &a,int b){
	if(a<b){
		a=b;
	}
	return;
}

void chmini(int &a,int b){
	if(a>b){
		a = b;
	}
	return;
}



int main() {
  int N;
  cin >> N;
  if(N%10==2||N%10==4||N%10==5||N%10==7||N%10==9){
    cout << "hon";
  }
  else if(N%10==3){
    cout << "bon";
  }
  else{
    cout << "pon";
  }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s; cin >> s;
    rep(i,s.size()){
        if(s[i] == '1') s.replace(i,1,"9");
        else s.replace(i,1,"1");
    }
    OUT(s);

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define str string
#define rep(x) for(int y=0;y<x;y++)
#define all(x) begin(x),end(x)
int main(){
    int A,B,C,D;
    vector<char>s(19);
    cin>>A;
    if(A<1200)cout<<"ABC"<<endl;
    else cout<<"ARC"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;

struct Idx { int ia, ib, ic; };
bool used[1003][1003][1003];
deque<Idx> que;
vector<ll> ans;

int main() {
	int X, Y, Z, K; cin >> X >> Y >> Z >> K;
	vector<ll> a(X), b(Y), c(Z);
	for (int i = 0; i < X; i++) cin >> a[i];
	for (int i = 0; i < Y; i++) cin >> b[i];
	for (int i = 0; i < Z; i++) cin >> c[i];
	sort(a.rbegin(), a.rend());
	sort(b.rbegin(), b.rend());
	sort(c.rbegin(), c.rend());
	que.push_back({ 0,0,0 });
	ll mi = 1e18;
	for (int i = 0; i < min(K + 10000000, X*Y*Z); i++) {
		if (que.empty()) break;
		auto idx = que.front(); que.pop_front();
		int ia = idx.ia, ib = idx.ib, ic = idx.ic;
		if (ans.size() > K && mi >= a[ia] + b[ib] + c[ic]) continue;
		ans.push_back(a[ia] + b[ib] + c[ic]);
		mi = min(mi, a[ia] + b[ib] + c[ic]);
		if (que.size() > 10000000) continue;
		if (ia + 1 < X && !used[ia + 1][ib][ic]) {
			que.push_back({ ia + 1, ib, ic });
			used[ia + 1][ib][ic] = true;
		}
		if (ib + 1 < Y && !used[ia][ib + 1][ic]) {
			que.push_back({ ia, ib + 1, ic });
			used[ia][ib + 1][ic] = true;
		}
		if (ic + 1 < Z && !used[ia][ib][ic + 1]) {
			que.push_back({ ia, ib, ic + 1 });
			used[ia][ib][ic + 1] = true;
		}
	}
	sort(ans.rbegin(), ans.rend());
	for (int i = 0; i < K; i++) cout << ans[i] << endl;
	return 0;
}





Measured memory_bytes: 985336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define REP(i, n) for(int i=0; i<n; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll mod = 1e9+7;

struct edge{
    int to;
    int cost;
};
using graph = vector<vector<edge>>;

int main(){
    int n, q; cin >> n >> q;
    str s; cin >> s;
    vector<int> ac(n-1, 0);
    for(int i=0; i<n-1; i++){
        if(s[i]=='A' && s[i+1]=='C'){
            ac[i] = 1;
        }
    }
    vector<int> accum(n-1, 0);
    accum[0] = ac[0];
    for(int i=0; i<n-1; i++){
        accum[i+1] = accum[i] + ac[i+1];
    }
    int start, end;
    REP(i, q){
        cin >> start >> end;
        if(start >= 2){
            cout << accum[end-2]-accum[start-2] << endl;
        }else{
            cout << accum[end-2] << endl;
        }
    }
}

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

const int MAXN = 100010;
int main() {
	int n, k, q;
	int right[MAXN];
	memset(right, 0, sizeof(right));
	cin>>n>>k>>q;
	for (int i=1; i<=q; i++) {
		int a;
		cin>>a;
		right[a]++;
	}
	for (int i=1; i<=n; i++) {
		int score = k - (q-right[i]);\
		if (score > 0)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}
	return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<string> S(N);
    for(int i=0; i<N; i++) cin >> S[i];

    vector<int> ans(4, 0);
    for(auto s : S)
    {
        if(s == "AC") ans[0]++;
        if(s == "WA") ans[1]++;
        if(s == "TLE") ans[2]++;
        if(s == "RE") ans[3]++;
    }

    cout << "AC x " << ans[0] << endl;
    cout << "WA x " << ans[1] << endl;
    cout << "TLE x " << ans[2] << endl;
    cout << "RE x " << ans[3] << endl;


    return 0;
}


Measured memory_bytes: 6364
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
#include <stack>
#include <map> // pair
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
typedef std::stack<int> IntStack;
typedef std::stack<char> charStack;
#define START 0
#define FORWARD 1
#define BACK 2
using namespace std;
using ll = long long;
typedef pair <ll, ll > pll;
bool comp(const pll &a, const pll &b) {
	return a.first < b.first;
}
//*********************************************************
// 最大公約数（Greatest Common Divisor）を返す。
// 引数に０がある場合は０を返す。
//*********************************************************
ll gcd(ll a, ll b)
{
	ll tmp, r;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	/* ユークリッドの互除法 */
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
	//// 引数に０がある場合は０を返す
	//if ((0 == m) || (0 == n))
	//	return 0;

	//// ユークリッドの方法
	//while (m != n)
	//{
	//	if (m > n) m = m - n;
	//	else         n = n - m;
	//}
	//return m;
}//gcd

int main()
{
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	ll x[100004] = {};
	ll y[100004] = {};
	ll z[10004] = {};
	ll connect[10004] = {};
	ll x2[10004] = {};
	ll z2[2004][2004] = { {} };
	ll z3[2004][2004] = { {} };
	vector<tuple<ll, ll>> vec;
	string s;
	string t;
	//IntStack yStack;
	//charStack Stack;
	//vector<pair<int, int> > pairs(a);
	//cout << LLONG_MAX<< endl;

	cin >> a;
	cin >> b;


	if (b > 1)
	{
		cout << (a - (b)+1)- 1 << endl;

	}
	else
	{
		cout << 0 << endl;

	}

	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//sort(x, x + a, std::greater<ll>());

//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得
//
//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}
//
//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え


/*vector<pair<ll, ll> > hoges(a);
for (int i = 0; i < a; i++)
{
cin >> x[i];
cin >> y[i];
hoges[i] = make_pair(x[i], y[i]);
}
sort(hoges.begin(),hoges.end(),comp);
for (int i = 0; i < a; i++)
{
if (hoges[i].second>=b)
{
ans += hoges[i].first*b;
break;
}
else
{
ans += hoges[i].first*hoges[i].second;
b -= hoges[i].second;

}
}*/

Measured memory_bytes: 256