akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 200000 + 10, K = 20;
int x[N],y[N],z[N],d[N],par[N],val[N];
int find(int x){
    if(x==par[x]) return x;
    return par[x] = find(par[x]);
}
int main(){
    int e,n,m;
    scanf("%d%d%d",&e,&n,&m);
    for(int i=1;i<=e;i++){
        scanf("%d%d%d",&x[i],&y[i],&z[i]);
        y[i] += n;
        d[i] = i;
    }
    sort(d+1,d+1+e,[](int i,int j){
         return z[i] > z[j];
    });
    ll ans = 0;
    for(int i=1;i<=n+m;i++) par[i] = i;
    for(int i=1;i<=e;i++){
        int u = x[d[i]], v = y[d[i]], w = z[d[i]];
        u = find(u), v = find(v);
        if(u!=v&&val[u]+val[v]<=1){
            val[v] |= val[u];
            par[u] = v;
            ans += w;
        }
        else if(val[u]==0){
            val[u] = 1;
            ans += w;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4224
#include <complex>
#include <iostream>
#include <stack>
#include <unordered_map>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <functional>
#include <iterator>
#include <tuple>
#include <set>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<int> ss;
    long long sum = 0;
    for (int i = 0; i < n; i++) {
        int aa = 0;
        cin >> aa;
        ss.push(aa);
        sum += aa;
    }
    long long disc = 0;
    for (int i = 0; i < m; i++) {
        int r = ss.top();
        disc += (r-r/2);
        ss.pop();
        ss.push(r/2);
    }
    
    cout << sum - disc << endl;
     return 0;
}


Measured memory_bytes: 892
#include<stdio.h>
#include<string.h>
int main(void){
    char S[1204]={'\0'};
    fgets(S,1200,stdin);
    for(int i=0;i<strlen(S);i++){
        if(S[i]>=65 && S[i]<=90){
            S[i]+=32;
        }else if(S[i]>=97 && S[i]<=122){
            S[i]-=32;
        }else{
            continue;
        }
    }
    printf("%s",S);
    return 0;
}


Measured memory_bytes: 2104
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef int64_t lint;
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using lb = long double;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SI(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define debug(x) cerr << #x << ": " << x << "\n"//手動デバッグ
#define debugV(x) for(int i=0;i<((ll)(x).size());i++)cerr << #x <<"at:"<<i<< ": " << x[i] << "\n"//手動デバッグ 
#define YES(c) cout<<((c)?"YES\n":"NO\n"),0
#define Yes(c) cout<<((c)?"Yes\n":"No\n"),0
#define O(p) cout<<p<<"\n",0
#define OS(p) cout<<p<<" ",0
#define ON(p) cout<<p,0
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define endl "\n"//endlを置き換える
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定

const int dy[4]={1,0,-1,0};
const int dx[4]={0,1,0,-1};//^>v<

template<class T=int> T in(){
    T x;
    cin>>x;
    return (x);
}
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;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
//------------------------------------------------------------





//------------------------------------------------------------
int main() {
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
//------------------------------------------------------------
    ll a,b,c,d;cin>>a>>b>>c>>d;
    O(max(a*c,max(b*d,max(d*a,c*b))));
    
    
    
    
    
    
    
    
//------------------------------------------------------------
	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define int long long





int N , M , Q;

int clauses[60][4];

int actu[20];
int maxi = 0;
void recursion(int in , int valActu)
{
	if (in == N)
	{
		//checer
		int ac = 0;
		for (int i = 0 ; i < Q ; i++)
		{
			if (actu[clauses[i][1]] - actu[clauses[i][0]] == clauses[i][2])
			{
				ac += clauses[i][3];
			}
		}
		maxi = max(maxi , ac);
		return;
	}
	for (int i = valActu ; i <= M ; i++)
	{
		actu[in] = i;
		recursion(in + 1 , i);
	}
}

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> N >> M >> Q;
	for (int i = 0 ; i < Q ; i++)
	{
		cin >> clauses[i][0] >> clauses[i][1] >> clauses[i][2] >> clauses[i][3];
		clauses[i][0]--; clauses[i][1]--;
	}
	recursion(0 , 1);
	cout<<maxi<<endl;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        10000005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<pii>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
 
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}
vector<int>spf(maxn+100);

void sieve(){
    for(int i = 2;i*i < maxn;++i){
        if(spf[i])continue;
        spf[i] = i;
        for(int j = i*i;j <= maxn;j += i){
            if(!spf[j])spf[j] = i;
        }
    }
    for(int i = 2;i < maxn;++i)if(!spf[i])spf[i] = i;
}


void solve(){ 
    int n,ans = 1;
    cin >> n;
    FOR(i,2,n+1){
        vector<pii>fa;
        int x = i,pro = 1;
        while(x > 1){
            int p = spf[x],tot = 0;
            while(x%p == 0)tot++,x /= p;
            pro *= tot+1;
        }
        ans += i*pro;
    }
    cout << ans << "\n";
}   

signed main()   
{
    showoff;
    sieve();
    int T = 1;
    //cin >> T;
    FOR(t,1,T+1){
        solve();
    }
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...

Measured memory_bytes: 81312
#include <sstream>
#include <iostream>

using namespace std;

int main() {

	int i = 1;
	int a;

	while (!cin.eof()) {

		cin >> a;

		if (a == 0) {
			break;
		}

		ostringstream count, output;
		count << i;
		output << a;

		string str;
		str = "Case " + count.str() + ": " + output.str();

		cout << str << "\n";

		i++;

	}

	return 0;
}


Measured memory_bytes: 3160
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int S=sc.nextInt();
        int hour = S / 3600;
        int minutes = (S % 3600) / 60;
        int seconds = (S % 3600)  % 60;
        System.out.println(hour+":"+minutes+":"+seconds);
    }
}


Measured memory_bytes: 26240
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
struct FenwickTree {
    seq: Vec<i64>,
}
#[allow(dead_code)]
impl FenwickTree {
    fn new(n: usize) -> FenwickTree {
        FenwickTree {
            seq: vec![0; n + 2],
        }
    }
    fn add(&mut self, index: usize, value: i64) {
        let mut index = (index + 1) as i32;
        while (index as usize) < self.seq.len() {
            self.seq[index as usize] += value;
            index += index & -index;
        }
    }
    // inclusive
    fn sum(&self, index: usize) -> i64 {
        let mut ret = 0;
        let mut index = (index + 1) as i32;
        while index > 0 {
            ret += self.seq[index as usize];
            index -= index & -index;
        }
        ret
    }
}

fn main() {
    let n = read::<usize>();
    let k = read::<i64>();
    let mut aseq = vec![0; n];
    let mut sums = vec![(0, 0); n + 1];
    for i in 0..n {
        aseq[i] = read::<i64>() - k;
        sums[i + 1].0 = sums[i].0 + aseq[i];
        sums[i + 1].1 = i + 1;
    }
    let mut ftree = FenwickTree::new(n + 10);
    sums.sort();
    let mut ans = 0;
    let mut index = 0;
    for &(v, pos) in sums.iter() {
        if pos == 0 || pos == n + 1 {
            continue;
        }
        while index <= n && sums[index].0 <= v {
            ftree.add(sums[index].1, 1);
            index += 1;
        }
        ans += ftree.sum(pos - 1);
    }
    println!("{}", ans);
}


Measured memory_bytes: 14588
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[100001]={0},f[100001]={0};
	for(int i=2;i<=100001;i++)
	{
		if(a[i]==0)
		{
			for(int j=i*2;j<=100001;j+=i)
			{
				a[j]=1;
			}
		}
	}
	a[1]=1;
	a[2]=0;
	for(int i=2;i<=100001;i++)
	{
		if(a[i]==0&&a[(i+1)/2]==0&&i%2!=0)
		{
			f[i]=f[i-1]+1;
		}else{
			f[i]=f[i-1];
		}
	}
	int n,l[100001],r[100001];
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>l[i]>>r[i];
		cout<<f[r[i]]-f[l[i]-1]<<endl;
	 } 
	return 0;	
} 

Measured memory_bytes: 5140
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define Cout(s) cout<<s<<endl
using namespace std;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

int a = 0, b = 0, c, d, n, k = 0, ans = 0;
string s, t;


int main()
{
	int h, w; cin >> h >> w;
	char ans[102][102];
	rep(i, w + 2) {
		ans[0][i] = '#'; ans[h + 1][i] = '#';
	}
	rep(i, h+1) { ans[i][0] = '#'; ans[i][w + 1] = '#'; }
	for (int i = 1; i < h + 1; i++)
		for (int j = 1; j < w + 1; j++)
			cin >> ans[i][j];
	rep(i, h + 2)
	{
		rep(j, w + 2)
		{
			cout << ans[i][j];
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 256
n = int(input())
cand = []
if n == 1:
    print(1)
else:
    for i in range(n, 1, -1):
        count = 0
        identifier = i
        while True:
            if i % 2 == 0:
                i /= 2
                count += 1
            else:
                cand.append([count, identifier])
                break
    cand.sort()
    print(cand[len(cand) - 1][1])


Measured memory_bytes: 3060
#include <iostream>
#define mod 1000000007
using namespace std;

int n,freq[200005];
int main()
{
cin>>n;
for(int i=1;i<n;i++)
{
    int x;
    cin>>x;
    freq[x]++;
}
for(int i=1;i<=n;i++)
{
    cout<<freq[i]<<'\n';
}
}


Measured memory_bytes: 4360
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<int, int> pii;
     
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     
mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

const int N = (int)2e5 + 9;
char s[N];

void NO(){
    cout << "No\n";
    exit(0);
}

bool check(int i, int j){   
    for(int t = i; t < j ; t ++ ){
        if(s[t] == '#' && s[t + 1] == '#')
            return false;
    }
    return true;
}

int main(){
    fastIO;
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    for(int i = 1; i <= n ; i ++ ){
        cin >> s[i];
    }
    if(!check(a,c) || !check(b,d))
        NO();
    if(c < d){
        cout << "Yes\n";
    }
    else{
        for(int i = max(b,2); i <= d; i ++ ){
            if(s[i] == '.' && s[i - 1] == '.' && s[i + 1] == '.'){
                cout << "Yes\n";
                return 0;
            }
        }
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 512
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
ans=B[A[0]-1]
for i in range(1,n):
  ans+=B[A[i]-1]
  if A[i]==A[i-1]+1:
    ans+=C[A[i-1]-1]
print(ans)

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

int main(void){
    int C[3][3];
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++) cin >> C[i][j];
    }
    int A[3],B[3];
    A[0]=0; B[0]=C[0][0]; B[1]=C[0][1]; B[2]=C[0][2];
    A[1]=C[1][0]-B[0]; A[2]=C[2][0]-B[0];

    bool flg=true;
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            if(C[i][j]!=A[i]+B[j]) flg=false;
        }
    }

    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 384
#include <cstdio>

using namespace std;

int d;
long long a[19];

long long dfs(long long x, long long y, long long z) {
    long long ans = 0;
    
    if (z < 0) return 0;
    
    if (y > x - y - 1) {
        if (z == d) ans = 1;
    } else {
        int p;
        long long c1 = z / a[y] % 10, c2 = d / a[y] % 10;
        
        if (y == 0) {
            p = 9;
        } else {
            p = 10;
        }
        
        if (c1 == c2) {
            ans += dfs(x, y + 1, z) * p;
        } else if (c1 > c2) {
            long long c = c1 - c2;
            
            ans += dfs(x, y + 1, z - a[y] * c + a[x - y - 1] * c) * (p - c);
            
            c = 10 - c;
            
            ans += dfs(x, y + 1, z + a[y] * c - a[x - y - 1] * c) * (p - c);
        } else {
            long long c = c2 - c1;
            
            ans += dfs(x, y + 1, z + a[y] * c - a[x - y - 1] * c) * (p - c);
            
            c = 10 - c;
            
            ans += dfs(x, y + 1, z - a[y] * c + a[x - y - 1] * c) * (p - c);
        }
    }
    
    return ans;
}

int main() {
    int i, j;
    long long ans = 0;
    
    scanf("%d", &d);
    
    a[0] = 1;
    
    for (i = 1; i < 19; i++) a[i] = a[i - 1] * 10;
    
    for (i = 2; i <= 18; i++) ans += dfs(i, 0, 0);
    
    printf("%lld\n", ans);
    
    return 0;
}


Measured memory_bytes: 128
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target ("avx")
#define io_init cin.tie(0);ios::sync_with_stdio(0);cout<<setprecision(10)
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
 
int calcScore(vector<int> &plan, vector<int> &c, vector<vector<int>> &s) {
	int D = 365;
	int score = 0;
	vector<int> last(26, -1);
	for (int i = 0; i < D; i++) {
		score += s[i][plan[i]];
		last[plan[i]] = i;
		for (int j = 0; j < 26; j++) {
			score -= c[j] * (i - last[j]);
		}
	}
	return score;
}
 
int main() {
	int D;
	cin >> D;
	vector<int> c(26);
	for (int i = 0; i < 26; i++)cin >> c[i];
	vector<vector<int>> s(365,vector<int>(26,0));
	for (int i = 0; i < D; i++) {
		for (int j = 0; j < 26; j++)cin >> s[i][j];
	}
	
	vector<int> plan(365, 0);
	for (int i = 0; i < 365; i++) {
		int mi = 0, m = -1;
		for (int j = 0; j < 26; j++) {
			if (m < s[i][j]) {
				mi = j;
				m = s[i][j];
			}
			plan[i] = j;
		}
	}
	int sc = calcScore(plan, c, s);
 
	for (int n = 0; n < 200000; n++) {
		int i = rand() % 365, j = rand() % 26, old = plan[i];
		plan[i] = j;
		int nsc = calcScore(plan, c, s);
		if (nsc > sc) {
			sc = nsc;
		}
		else {
			plan[i] = old;
		}
	}
 
	for (int i = 0; i < 365; i++) {
		cout << plan[i] + 1 << endl;
	}
}

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

int main(){
    int N;
    cin >> N;
    vector<pair<long long, long long>> A(N);
    for(int i = 0; i < N; i++){
        cin >> A[i].first >> A[i].second;
    }
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    cout << A[0].first + A[0].second << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;
template <class T>
vector<T> make_v(size_t size, const T& init){ return vector<T>(size, init); }

template<class... Ts>
auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }



int main() {
    int n, m;
    cin >> n >> m;
    auto v = make_v(2, 2*n, 0);
    for (int i = 0; i < 2*n; ++i) {
        v[0][i] = i;
    }
    for (int i = 0; i < m; ++i) {
        int now = i%2, nxt = (i+1)%2;
        int k;
        cin >> k;
        if(k == 0){
            for (int j = 0; j < n; ++j) {
                v[nxt][2*j] = v[now][j];
                v[nxt][2*j+1] = v[now][j+n];
            }
        }else {
            for (int j = 0; j < 2 * n; ++j) {
                v[nxt][(j-k+2*n)%(2*n)] = v[now][j];
            }
        }
    }
    for (int i = 0; i < 2*n; ++i) {
        cout << v[m%2][i]+1 << "\n";
    }
    return 0;
}



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

const int INF = 1e7;

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

    vector<int> a(m);
    for(int i=0; i<m; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());

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

    vector<int> interval(m-1);
    for(int i=0; i<m-1; i++){
        interval[i] = a[i+1] - a[i];
    }
    sort(interval.begin(),interval.end());
    reverse(interval.begin(),interval.end());

    int ans = a[m-1] - a[0];
    for(int i=0; i<n-1; i++){
        ans -= interval[i];
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  long long w,h;cin>>w>>h;
  long long int x,y; cin >> x >> y;
  long double area = w/2.0 * h;
  int flag = 0;
  if (w == 2 * x && h == 2 * y)
  {
    flag = 1;
  }
  cout << fixed << setprecision(10) << area << ' ' << flag << endl;
  
}

Measured memory_bytes: 3788
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  vector<int>ve(3);
  bool flag=false;
  int ans[4]={};
  while(cin>>ve[0]>>ve[1]>>ve[2]){
    if(flag)continue;
    sort(ve.begin(),ve.end(),greater<int>());
    if(ve[0]>=ve[1]+ve[2]){
      flag=true;
      continue;
    }
    if((ve[0]*ve[0])==(ve[1]*ve[1]+ve[2]*ve[2])){
      ans[0]++;
      ans[1]++;
    }else if(ve[0]*ve[0]<ve[1]*ve[1]+ve[2]*ve[2]){
      ans[0]++;
      ans[2]++;
    }else{
      ans[0]++;
      ans[3]++;
    }
    //cout<<ans[0]<<" "<<ans[1]<<" "<<ans[2]<<" "<<ans[3]<<endl;
  }
  cout<<ans[0]<<" "<<ans[1]<<" "<<ans[2]<<" "<<ans[3]<<endl;
  return 0;
}



Measured memory_bytes: 3128
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  int cnt = 1;

  for(int i = 1; i<=n-1; i++) {
    int v = h[i];
    bool ok = true;
    for(int j = 0; j <= i; j++) {
      if(v < h[j]) ok = false;
    }
    if(ok) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <cmath>

using namespace std;
const long long INF = (long long) (1e18)+1;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while (a > 0 && c > 0) {
    c -= b;
    if (c <= 0) {
      cout << "Yes" << endl;
      break;
    }
    a -= d;
    if (a <= 0) {
      cout << "No" << endl;
      break;
    }
  }
  return 0; 
}

Measured memory_bytes: 3604
#include<stdio.h>
#define null -1

int sibling(int);
int degree(int);
int Height(int);
int depth(int);
void print(int);

typedef struct{
  int parent,left,right;
}node;

node tree[25];
int height[25];

int main(){
  int i,j;
  int n;
  int id;
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    tree[i].parent=tree[i].right=tree[i].left=null;
  }
  for(i=0;i<n;i++) {
    scanf("%d",&id);
    scanf("%d%d",&tree[id].left,&tree[id].right);
    tree[tree[id].left].parent=id;
    tree[tree[id].right].parent=id;
    }
  for(i=0;i<n;i++)
    print(i);

 
  
  return 0;
}

int degree(int i){
  int count=0;
  if(tree[i].left!=null)
    count++;
  if(tree[i].right!=null)
    count++;
  return count;
}

int sibling(int i){
  if(tree[i].parent==null)
    return null;
  else {
    if(tree[tree[i].parent].left==i) return tree[tree[i].parent].right;
    if(tree[tree[i].parent].right==i) return tree[tree[i].parent].left;
  }
}

int depth(int i){
  int dep=0;
  while(tree[i].parent!=null){
    i=tree[i].parent;
    dep++;  
  }
  return dep;
}

int Height(int i){
  int h1=0;
  int h2=0;
  if(tree[i].left!=null) h1=Height(tree[i].left)+1;
  if(tree[i].right!=null) h2=Height(tree[i].right)+1;

  if(h1>h2)height[i]=h1;
  else height[i]=h2;
  return height[i];
}

void print(int i){
  printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,tree[i].parent,sibling(i),degree(i),depth(i),Height(i));

  if(tree[i].parent==null) printf("root\n");
  else if(tree[i].left==null&&tree[i].right==null) printf("leaf\n");
  else printf("internal node\n");
}



Measured memory_bytes: 2104
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>

#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;

void printVector(vector<int> v) {
	for (auto vv : v)
		cout << vv << " ";
	cout << endl;
}

int main(int argc, char *argv[]) {
    int h, w, k;
    cin >> h >> w >> k;
    int rep = 0;
    int n = 1;
    vector<int> lastv;
    for (int i = 0; i < h; i++) {
    	string s;
    	cin >> s;
    	vector<int> v;
    	bool hasF = false;
    	for (auto ss : s) {
    		if (ss == '.') {
    			v.push_back(n);
    		}
    		else {
    			if (hasF == false) {
    				hasF = true;
    				v.push_back(n);
    			}
    			else {
    				n++;
    				v.push_back(n);
    			}
    		}
    	}
    	if (hasF == false) {
    		rep++;
    		continue;
    	}
    	lastv = v;
    	while (rep > 0) {
    		printVector(v);
    		rep--;
    	}
    	printVector(v);
    	n++;
    }
    while (rep > 0) {
    	rep--;
    	printVector(lastv);
    }
}


Measured memory_bytes: 768
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
bool vis[30];
char s[100005];
int main(){
    while(~scanf("%s",s)){
        memset(vis,0,sizeof(vis));
        int i;
        for(i=0;s[i];i++){
            vis[s[i]-'a']=1;
        }
        for(i=0;i<26;i++){
            if(vis[i]==0){
                printf("%c\n",i+'a');
                break;
            }
        }
        if(i==26) printf("None\n");
    }
return 0;}


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

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

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int a;
    string s;
    cin >> a >> s;

    if (a >= 3200) {
        cout << s << endl;
    } else {
        cout << "red" << endl;
    }
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

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

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p;
const int inf=(1<<30);
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
	
int main(){
	ll a,b,t;
	cin>>a>>b>>t;
	ll ans=0;
	while(t>0){
		t-=a;
		if(t<0)break;
		ans+=b;
	}
	cout<<ans<<endl;
	
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long int n, m;
    cin >> n >> m;
    long long int a[m], sum = 0;
    for(int i = 0 ; i < m ; i++){
    	cin>>a[i];
    	sum += a[i];
    }
    if(n-sum >=0 )cout<<n-sum<<"\n";
    else cout<<-1<<"\n";
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
const int MAX=100005;
vector<int> llist[MAX];
int n,depth[MAX];
void dfs(int v)
{
	vector<int> temp;
	if(llist[v].size()==0){
		depth[v]=0;
		return;
	}
	temp.clear();
	for(int i=0;i<llist[v].size();++i){
		int u=llist[v][i];
		dfs(u);
		temp.push_back(depth[u]);
	}
	sort(temp.begin(),temp.end());
	depth[v]=-1;
	for(int i=0;i<temp.size();++i){
		temp[i]+=(llist[v].size()-i);
		if(depth[v]<temp[i]) depth[v]=temp[i];
	}
}
int main()
{
	int a;
	cin>>n;
	for(int i=2;i<=n;++i){
		cin>>a;
		llist[a].push_back(i);
	}
	dfs(1);
	cout<<depth[1]<<endl;
	return 0;
}

Measured memory_bytes: 13952
#include <iostream>
#include <algorithm>
#include <cstdlib>
using namespace std;

int main() {
	int a = 0;
	int b = 0;

 	while (cin >> a >> b) {
 		int sum = a + b;
	
		int i = 0;
		while (sum != 0) {
			sum /= 10;
			i++;
		}
		cout << i << endl;
 	}

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#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++)
#define Clear(a) a = decltype(a)() //queueのclear
#define all(s) (s).begin(),(s).end()
typedef long long ll;
typedef pair<int,int> p;
//const ll big=998244353;
const ll big=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}
ll inv(ll x){
    return expm(x,big-2);
}

  ll find(ll l,ll r,vector<vector<ll>> &dp,int n,ll wm){
    if(r-l==1)return l;
    ll s=(l+r)/2;
    if(dp[n][s]>wm)return find(l,s,dp,n,wm);
    else return find(s,r,dp,n,wm);
  };

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

  int n;
  cin >> n;
  if(n%2==0){
    cout << n*(n-1)/2-(n+1)/2 << endl;
    rep2(i,1,n)rep2(j,i+1,n+1){
      if(i+j!=n+1)cout << i << ' ' << j << endl;
    }
  }else{
    cout << n*(n-1)/2-n/2 << endl;
    rep2(i,1,n)rep2(j,i+1,n+1){
      if(i+j!=n)cout << i << ' ' << j << endl;
    }
  }
}
/*
N:odd
{1,N-1},{2,N-2},...,{i,N-i},...,{(N-1)/2,(N+1)/2},{N}
N:even
{1,N},{2,N-1},...,{i,N-i+1},...,{N/2,N/2+1}
*/

Measured memory_bytes: 3660
#include "bits/stdc++.h"
#include <unordered_map>
#include <unordered_set>
using namespace std;

vector<vector<int>> dirs = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };

int bfs(vector<vector<char>>& matrix, int row, int col) {
	int n = matrix.size();
	int m = matrix[0].size();
	vector<vector<bool>> used(matrix.size(), vector<bool>(matrix[0].size(), false));

	queue<tuple<int, int, int>> q;
	tuple<int, int, int> t2{ row, col, 0 };

	q.push(t2);

	used[row][col] = true;

	int res = 0;

	while (q.size() > 0) {
		auto current = q.front();
		q.pop();
		int r = get<0>(current);
		int c = get<1>(current);
		int val = get<2>(current);

		res = max(res, val);

		for (auto dir : dirs) {
			int nextRow = r + dir[0];
			int nextCol = c + dir[1];
			if (nextRow < n && nextCol < m && nextRow >= 0 && nextCol >= 0 && matrix[nextRow][nextCol] == '.' && !used[nextRow][nextCol]) {
				tuple<int, int, int> newT{ nextRow, nextCol, val + 1 };
				q.push(newT);
				used[nextRow][nextCol] = true;
			}
		}
	}

	return res;
}

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

	vector<vector<char>> matrix(n, vector<char>(m, ' '));

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> matrix[i][j];
		}
	}
	int ans = 0;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (matrix[i][j] != '#') {
				ans = max(ans, bfs(matrix, i, j));
			}
		}
	}

	cout << ans;
}


Measured memory_bytes: 256
"use strict"

const fs = require("fs");

Array.prototype.group =
    function* (key) {
        if ( this.length === 0 )
            return;

        if (key === undefined)
            key = (a) => { return a; };
        
        let val = key(this[0]);
        let from_idx = 0;
        let curr_idx = 1;
        while( curr_idx < this.length ){
            let val2 = key(this[curr_idx]);
            if (val !== val2) {
                yield this.slice(from_idx, curr_idx);
                val = val2;
                from_idx = curr_idx;
                curr_idx++;
            } else
                curr_idx++;
        }

        yield this.slice(from_idx);
    }

let inputs = fs.readFileSync("/dev/stdin").toString().split("\n");
let N = Number(inputs[0]);
let as = inputs[1].split(" ").map(Number);

console.log(
    Array.from(as.group())
        .map((a) => { return Math.floor(a.length/2); })
        .reduce((a, b) => { return a+b; }, 0));



Measured memory_bytes: 7372
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll p, ll n, ll m) {
	if (n == 0) return 1;
	else if (n == 1) return p % m;
	else if (n % 2 == 1) return p * pow_mod(p, n - 1, m) % m;
	else {
		ll tmp = pow_mod(p, n / 2, m);
		return (tmp * tmp) % m;
	}
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

ll com_mod(ll n, ll k, ll m) {
	if (k == 0) return 1;
	else {
		ll x = 1;
		ll y = 1;
		for (ll i = 0; i < k; i++) {
			x = (x * (n - i)) % m;
			y = (y * (i + 1)) % m;
		}
		ll res = (x * pow_mod(y, m - 2, m)) % m;
		return res;
	}
}

int main() {
	string s; cin >> s;
	for (int i = 0; i < 3; i++) {
		if (s[i] == s[i + 1]) {
			cout << "Bad" << endl;
			return 0;
		}
	}
	cout << "Good" << endl;
	return 0;
}

Measured memory_bytes: 3628
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    def f(w, h):
        w2 = w+2
        la = ['#' * w2]
        ra = ['#' * w2]
        ls = rs = None
        for i in range(1,h+1):
            lt, rt = LS()
            if 'L' in lt:
                ls = (i, lt.index('L') + 1)
            if 'R' in rt:
                rs = (i, rt.index('R') + 1)
            la.append('#' + lt + '#')
            ra.append('#' + rt + '#')
        la.append('#' * w2)
        ra.append('#' * w2)

        q = collections.deque([(ls[0], ls[1], rs[0], rs[1])])
        v = collections.defaultdict(bool)
        v[(ls[0], ls[1], rs[0], rs[1])] = 1
        while q:
            ly,lx,ry,rx = q.pop()
            for dy, dx in dd:
                lty = ly + dy
                ltx = lx + dx
                rty = ry + dy
                rtx = rx - dx
                if la[lty][ltx] == '#':
                    lty = ly
                    ltx = lx
                if ra[rty][rtx] == '#':
                    rty = ry
                    rtx = rx
                if v[(lty,ltx,rty,rtx)]:
                    continue
                v[(lty,ltx,rty,rtx)] = 1
                if la[lty][ltx] == '%' and ra[rty][rtx] == '%':
                    return 'Yes'
                if la[lty][ltx] != '%' and ra[rty][rtx] != '%':
                    q.append((lty,ltx,rty,rtx))

        return 'No'

    while True:
        w,h = LI()
        if w == 0 and h == 0:
            break
        rr.append(f(w,h))

    return '\n'.join(rr)



print(main())



Measured memory_bytes: 288720
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> T;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
#define mp make_pair
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;
using Ki = vector<vector<int>>;
// using vec = vector<int>;

#include <cstdint>
 
template <long long Modulus> class modint {
  long long a;
 
public:
  constexpr modint(const long long x = 0) noexcept : a((x % Modulus + Modulus) % Modulus) {}
  constexpr long long val() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr bool operator==(const modint rhs) const noexcept {
    return modint(*this).val() == rhs.val();
  }
  modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  modint &operator/=(modint rhs) noexcept {
    long long exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};
using mint = modint<MOD>;
typedef vector<mint> vec;
typedef vector<vector<mint>> mat;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    int n,k;
    cin >> n >> k;
 
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
        if(a[i]<0){
            // a[i]+=MOD;
        }
    }
 
    sort(a.begin(),a.end());
  
    vec fact(n+1,1);
    rep(i,n) fact[i+1] = fact[i]*(i+1);
 
    mint ans = 0;
    rep(i,n-k+1){
        ans -= fact[n-1-i] / fact[k-1] / fact[n-k-i] * a[i];
    }
 
    reverse(a.begin(),a.end());
    rep(i,n-k+1){
      ans += fact[n-1-i] / fact[k-1] / fact[n-k-i] * a[i];
    }
 
    cout << ans.val() << endl;
    
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
  	int h,n;
  cin>>h>>n;
  int sum=0;
  for(int i=0;i<n;i++){
  	int a;
    cin>>a;
    sum+=a;
  }
  if(sum>=h)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}

vector<ll> pw2(51,1);vector<ll> pw10(19,1);
ll high_order_bit(ll n){
    ll tmp=1,i=-1;
    while(tmp<=n){
        tmp*=2;
        i++;
    }
    if(n==0) return 0;
    else return i;
}
vector<ll> binary_expansion(ll n){
    vector<ll> B(high_order_bit(n)+1);
    ll tmp=n;
    for(ll i=high_order_bit(n);i>=0;i--){
        B[i]=tmp/pw2[i];
        tmp%=pw2[i];
    }
    return B;
}
vector<ll> divisor(ll x){
    vector<ll> div;
    for(int i=1;i*i<=x;i++){
        if(i*i!=x && x%i==0){
            div.pb(i);
            div.pb(x/i);
        }
        else if(x%i==0) div.pb(i);
    }
    sort(all(div));
    return div;
}
vector<ll> vectorprime(ll x){
    vector<bool> is_prime(x+1);
    vector<ll> prime;
    rep(i,x+1) is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
    for(int i=2;i<=x;i++){
        if(is_prime[i]){
            prime.pb(i);
        }
        for(int j=i*2;j<=x;j+=i) is_prime[j]=false;
    }
    return prime;
}
ll binary_search(vector<ll> v,ll key){ //key以上が初めて出てくる添字(0-index)
    int l=0,r=sz(v)-1;
    while(r-l>=1){
        int i=(l+r)/2;
        //cout<<l<<" "<<r<<" "<<i<<endl;
        if(v[i]<key) l=i+1;
        else r=i;
    }
    if(v[l]>=key) return l;
    else return INF;
}

int main(){
    string s,t; cin>>s>>t;
    if((s[0]==t[2]) && (s[1]==t[1]) && (s[2]==t[0])) cout<<"YES";
    else cout<<"NO";
    
}


Measured memory_bytes: 3544
num_diamond   = 0
num_rectangle = 0
while line = $stdin.gets
	data = line.chomp.split(/,/).map{|n| n.to_i }
	a = data[ 0 ]
	b = data[ 1 ]
	c = data[ 2 ]
	num_diamond   += 1 if a == b
	num_rectangle += 1 if a * a + b * b == c * c
end
puts num_rectangle
puts num_diamond


Measured memory_bytes: 6084
import java.util.Scanner;


public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a=Integer.parseInt(sc.next());
		int b=Integer.parseInt(sc.next());;
		int sum=0;

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

}

Measured memory_bytes: 22740
#include <iostream>
    using namespace std;
     
    int main() {
    // your code goes here
    int n;
    cin>>n;
    int a[110];
    for(int i=0;i<n;i++){
    cin>>a[i];
    }
    int ans=0;
    for(int i=n-1;i>-1;i--){
    for(int j=0;j<i;j++){
    if(a[j]>a[j+1]){
    int l=a[j+1];
    a[j+1]=a[j];
    a[j]=l;
    ans++;
    }
     
    }
     
    }
    for(int i=0;i<n-1;i++)cout<<a[i]<<" ";
    cout<<a[n-1]<<endl;
    cout<<ans<<endl;
    return 0;
    }

Measured memory_bytes: 1160
#include<stdio.h>
#include <iomanip>
#include <iostream>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include <random>
#include <chrono>

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

using namespace std;
int main() {
	string s, t;
	int ans = 0;
	cin >> s >> t;
	rep(i, s.size()) {
		if (s.at(i) == t.at(i)) {
			ans++;
		}
	}
	cout << ans;
}

Measured memory_bytes: 888
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())

if __name__=='__main__':
    n = I()
    c = list(S())
    i,j = 0,n-1
    ans = 0
    while i<j:
        while c[i]=='R':
            i += 1
            if i==n:
                break
        while c[j]=='W':
            j -= 1
            if j==-1:
                break
        if i<j:
            c[i],c[j] = c[j],c[i]
            i += 1
            j -= 1
            ans += 1
    print(ans)
    exit()

Measured memory_bytes: 10708
#include <iostream>
#include <algorithm>
using namespace std;
int N, M, Q;
int A[50];
int B[50];
int C[50];
int D[50];
int V[11];

int dfs(int idx) {
  if (idx == N) {
    int ret = 0;
    for (int i=0; i<Q; i++) {
      if (V[B[i]-1] - V[A[i]-1] == C[i]) {
        ret += D[i];
      }
    }
    return ret;
  }
  int st = (idx == 0) ? 1 : V[idx-1];
  int ret = 0;
  for (int i=st; i<=M; i++) {
    V[idx] = i;
    int d = dfs(idx + 1);
    ret = max(ret, d);
  }
  return ret;
}

int main() {
  ios::sync_with_stdio(false);
  cin >> N >> M >> Q;
  for (int i=0; i<Q; i++) {
    cin >> A[i] >> B[i] >> C[i] >> D[i];
  }
  int ret = dfs(0);
  cout << ret << endl;
}

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

using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;

#define out(a) cout << a << endl
#define out1(a) cout << a
#define in(a) cin >> a
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define rep(i, N) for (ll i = 0; i < (ll)N; i++)
#define rep1(i, N) for (ll i = 1; i <= (ll)N; i++)
#define repi(i, j, N) for (ll j = (ll)i + 1; j < (ll)N; j++)
#define all(v) v.begin(), v.end()

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;
}

constexpr int inf = 1e9;
constexpr ll linf = 1e18;
constexpr ll mod = 1e9 + 7;
constexpr int MAX = 200020;

int siz[MAX];
int par[MAX];
int ran[MAX];
void init(int n)
{
    rep(i, n)
    {
        par[i] = i;
        ran[i] = 0;
        siz[i] = 1;
    }
}

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 (ran[x] < ran[y])
    {
        par[x] = y;
        siz[x] += siz[y];
        siz[y] = siz[x];
    }
    else
    {
        par[y] = x;
        siz[x] += siz[y];
        siz[y] = siz[x];
        if (ran[x] == ran[y])
        {
            ran[x]++;
        }
    }
}

bool same(int x, int y)
{
    return find(x) == find(y);
}

vvi fr;
vi bl;

void solve()
{
    int n, m, k;
    in3(n, m, k);
    fr.resize(n);
    bl.assign(n, 0);
    init(n);
    rep(i, m)
    {
        int a, b;
        in2(a, b);
        a--, b--;
        fr[a].push_back(b);
        fr[b].push_back(a);
        unite(a, b);
    }
    rep(i, k)
    {
        int a, b;
        in2(a, b);
        a--, b--;
        if (same(a, b))
        {
            bl[a]++, bl[b]++;
        }
    }
    rep(i, n)
    {
        int ans = siz[find(i)] - fr[i].size() - bl[i] - 1;
        cout << ans << " ";
    }
    cout << endl;
}

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


Measured memory_bytes: 8312
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
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;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<int> a(n,0);
    vector<set<int>> children(n);
    repr(i,1,n){
        cin>>a[i];
        a[i]--;
        children[a[i]].insert(i);
    }

    vector<int> memo(n,-1);
    stack<int> stk;
    stk.push(0);
    while(!stk.empty()){
        DEBUG{
            printf("now: %d\n", stk.top());
            printf("memo: %d\n", memo[stk.top()]);
        }
        int now = stk.top();
        bool flg = true;
        if(children[now].size()==0){
            memo[now]=0;
            stk.pop();
            continue;
        }
        for(auto x:children[now]){
            if(memo[x]==-1){
                flg = false;
                stk.push(x);
            }
        }
        if(flg){
            vector<int> vec;
            for(auto x:children[now]){
                vec.push_back(memo[x]);
            }
            sort(begin(vec),end(vec));
            int depth = 0;
            rep(i,vec.size()){
                depth = max(depth, vec[i])+1;
            }
            memo[now] = depth;
            stk.pop();
        }
    }
    cout << memo[0] << endl;
    return 0;
}


Measured memory_bytes: 11340
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:isize,
    b:isize,
    }
    println!("{}",max(a+b,max(a-b,a*b)))
}

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

#define gap " "
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ok cout<<"ok"<<endl
#define dbg(x) cout<<(#x)<<" is "<<x<<endl
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

const int N=100009;

int main()
{
  //fastio; 
  ll n,r,sum=0;
  scanf("%lld",&n);

  sum+=(n/11);
  sum*=2;
  n=n%11;

  if(n>6) sum+=2;
  else if(n>0) sum+=1;

  printf("%lld\n", sum);
   return 0;
}

Measured memory_bytes: 256