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

using namespace std;

string s;

int eval(int x) {
	set<char> a;
	for (int i = 0; i < x; i++){
		a.insert(s[i]);
	}
	int r = 0;
	set<char> b;
	for (int i = x; i < s.length(); i++){
		b.insert(s[i]);
	}
	for (auto y : b) {
		r+=a.count(y);
	}
	return r;
}

int main() {
	int n;
	cin >> n;
	cin >> s;
	int best = 0;
	for (int i = 1; i < s.length(); i++){
		best = max(best,eval(i));
	}
	cout << best << "\n";
}


Measured memory_bytes: 3652
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>

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

int main()
{
	ll X,Y;
	scanf("%lld %lld",&X,&Y);
	if(X%Y==0) puts("-1");
	else
	{
		printf("%lld\n",X);
	}
	return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {

	public static long gcd(long a, long b) {
		if (a < b) {
			long tmp = a;
			a = b;
			b = tmp;
		}
		if (b == 1)
			return b;
		long r = a % b;
		if (r == 0)
			return b;
		return gcd(b, r);
	}

	public static long lcd(long a, long b) {
		long g = gcd(a, b);
		return (a / g) * b;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong(), b = sc.nextLong(), c = sc.nextLong(), d = sc.nextLong();
		sc.close();
		long g = lcd(c, d);
		long f = 0;
		if (a % c == 0)
			f = 1;
		long cnt = (b / c) - (a / c) + f;
		f = 0;
		if (a % d == 0)
			f = 1;
		cnt += (b / d) - (a / d) + f;
		f = 0;
		if (a % g == 0)
			f = 1;
		cnt -= (b / g) - (a / g) + f;
		cnt = b - a + 1 - cnt;
		System.out.println(cnt);
	}
}


Measured memory_bytes: 22868
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

void solve(){
    ll n,m;cin>>n>>m;
    vl cnt(n);
    rep(i,m){
        ll a,b;cin>>a>>b;
        ++cnt[a-1];
        ++cnt[b-1];
    }

    rep(i,n){
        if(cnt[i]%2){
            cout<<"NO"<<endl;
            return;
        }
    }
    cout<<"YES"<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#include<cstring>
using namespace std;
const int maxn=1e5+10;
long long ans=0;
int cnt=0;
int nums[maxn];
map<long long,int> S;
int main()
{
    int N;scanf("%d",&N);for(int i=1;i<=N;i++)
    {
        char str[16];scanf("%s",str+1);
        sort(str+1,str+11);
        long long now=0;
        for(int x=1;x<=10;x++)
        {
            now*=26;now+=str[x]-'a';
        }
        if(!S.count(now))
        {
            S[now]=++cnt;
            nums[cnt]=1;
        }else
        {
            int have=S[now];
            ans+=nums[have];
            nums[have]+=1;
        }
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 6912
#include<iostream>
#include<string.h>
using namespace std;

int main(void){

  char word[25];
  int i,length;
  
  cin >> word;
  length = strlen(word);
  
  for(i = length - 1; i >=0; i--){
   cout << word[i];
  }
  
  cout << endl;
  
  return 0;

}

Measured memory_bytes: 1132
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));



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

	int a[7] = { 1,3,5,7,8,10,12 };
	int b[4] = { 4,6,9,11 };
	int c[1] = { 2 };

	int x, y;
	cin >> x >> y;


	bool xf = false, yf = false;
	REP(i, 7) {
		if (a[i] == x)xf = true;
		if (a[i] == y)yf = true;
	}

	if (xf&&yf) {
		cout << "Yes" << endl;
		return 0;
	}
	xf = false;
	yf = false;


	REP(i, 4) {
		if (b[i] == x)xf = true;
		if (b[i] == y)yf = true;
	}
	if (xf&&yf) {
		cout << "Yes" << endl;
		return 0;
	}


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



Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    typedef long long lint;
    typedef pair<int,int> pint;
    typedef vector<int> vint;
    #define rep(i, n) for(int i = 0; i < n; i++)
    #define rep2(elem, vec) for(auto elem: vec)
    #define SORT(V) sort((V).begin(),(V).end())
    #define RSORT(V) sort((V).rbegin(), (V).rend())
    #define COUT(N) cout<<fixed<<setprecision(N)
    lint gcd(int a,int b){return b?gcd(b,a%b):a;}
    lint lcm(int a,int b){return a*b/gcd(a,b);}
    lint comb(int a,int b){return b?comb(a-1,b-1)*a/b:1;}
    int dx[4] ={1,0,-1,0},dy[4] = {0,1,0,-1};
    int MOD = 1e9+7;

int main(){
    int A,B,M;
    cin >> A >> B >> M;
    vint a(A),b(B);
    rep(i,A)cin >> a[i];
    rep(i,B)cin >> b[i];
    int ans = *min_element(a.begin(),a.end()) + *min_element(b.begin(),b.end());
    rep(i,M){
        int p1,p2,v;
        cin >> p1 >> p2 >> v;
        if(ans > a[p1-1]+b[p2-1]-v) ans = a[p1-1]+b[p2-1]-v;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

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

int main() {
	ll N, X, Y, Z;
	cin >> N >> X >> Y >> Z;

	ll M = 17;

	vvmint dp(N + 1, vmint(1 << M, 0));
	dp[0][0] = 1;

	rep(i, N)rep(j, 1 << M) {
		repn(k, 10) {
			ll t = ((j << k) & ((1 << M) - 1)) + (1 << (k - 1));

			if ((t >> (X - 1)) & 1 && (t >> (X + Y - 1)) & 1 && (t >> (X + Y + Z - 1)) & 1) { continue; }
			dp[i + 1][t] += dp[i][j];
		}
	}

	//repn(i, N)rep(j, 1 << M) {
	//	if(dp[i][j]!=0)cout << i << j <<" "<< dp[i][j] << endl;
	//}

	mint ans = 1;
	repn(i, N)ans *= 10;

	rep(j, 1 << M)ans -= dp[N][j];
	cout << ans << endl;
}


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

int main()
{
    int N;
    cin >> N;
    map<string, int> score;
    for (int i = 0; i < N; i++)
    {
        string s;
        cin >> s;
        score[s]++;
    }
    int M;
    cin >> M;
    for (int i = 0; i < M; i++)
    {
        string s;
        cin >> s;
        score[s]--;
    }
    int max_score = 0;
    for (auto p : score)
    {
        max_score = max(max_score, p.second);
    }
    cout << max_score << endl;
    return 0;
}

Measured memory_bytes: 3632
function main(input) {
  const inputs = input.trim().split('\n');
  var N = inputs[0];
  var N1 = N.slice(-1);

  if ('24579'.includes(N1)) {
    console.log('hon');
  } else if ('0168'.includes(N1)) {
    console.log('pon');
  } else {
    console.log('bon');
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29640
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format, std.datetime;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long H, W;
    scan(H, W);
    auto A = new string[](H);
    foreach (i; 0 .. H)
        A[i] = sread();
    auto dp = new long[][](H, W);
    dp[0][0] = 1;
    foreach (h; 0 .. H - 1)
    {
        foreach (w; 0 .. W - 1)
            if (A[h][w] == '.')
            {
                dp[h + 1][w] = (dp[h + 1][w] + dp[h][w]) % MOD;
                dp[h][w + 1] = (dp[h][w + 1] + dp[h][w]) % MOD;
            }
        if (A[h][W - 1] == '.')
            dp[h + 1][W - 1] = (dp[h + 1][W - 1] + dp[h][W - 1]) % MOD;
    }
    foreach (w; 0 .. W - 1)
        if (A[H - 1][w] == '.')
            dp[H - 1][w + 1] = (dp[H - 1][w + 1] + dp[H - 1][w]) % MOD;
    writeln(dp[$ - 1][$ - 1]);
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin >> s >> t;
    bool jadge=0,check=0;
    for(int i=s.size()-1;i>=0;i--){
        if(s[i]==t[0] || s[i]=='?'){
            for(int j=0;j<t.size();j++){
                if(s[i+j]!=t[j] && s[i+j]!='?'){
                    jadge=1;
                    break;
                }
            }
            if(jadge==0){
                check=1;
                for(int j=0;j<t.size();j++){
                    s[i+j]=t[j];
                }
                break;
            }
            jadge=0;
        }
    }
    if(check==1){
        for(int i=0;i<s.size();i++){
            if(s[i]=='?'){
                s[i]='a';
            }
        }
        cout << s << endl;
    }
    else {
        cout << "UNRESTORABLE" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

long long pow_mod(long long x, long long n, long long mod_num) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) { res = (res * x) % mod_num; }
        x = (x * x) % mod_num;
        n = (n >> 1);
    }
    return res;
}

class Combi_Num {
    public:
    long long mod_num;
    std::vector<long long> factorial, factorial_inv, inv, pow_val, pow_inv;
    Combi_Num() {}
    Combi_Num(const int n, const long long mod_num_in) {
        mod_num = mod_num_in;
        factorial.resize(n+1, 0);
        factorial_inv.resize(n+1, 0);
        inv.resize(n+1, 0);
        pow_val.resize(n+1, 0);
        pow_inv.resize(n+1, 0);
        factorial[0] = 1;
        factorial_inv[0] = 1;
        inv[0] = 1;
        pow_val[0] = 1;
        pow_inv[0] = 1;
        for (int i = 1; i <= n; i++) {
            factorial[i] = (factorial[i-1] * i) % mod_num;
            inv[i] = pow_mod(i, mod_num - 2, mod_num);
            factorial_inv[i] = (factorial_inv[i-1] * inv[i]) % mod_num;
        }

        for (int i = 1; i <= n; i++) {
            pow_val[i] = (pow_val[i-1] * 2) % mod_num;
            pow_inv[i] = (pow_inv[i-1] * inv[2]) % mod_num;
        }
    }

    long long combi(const int n, const int r) {
        return (factorial[n] * ((factorial_inv[r] * factorial_inv[n-r]) % mod_num)) % mod_num;
    }

    long long perm(const int n, const int r) {
        return (factorial[n] * factorial_inv[n-r]) % mod_num;
    }
};

const long long MOD = 1000000007;
const int MAX_SIZE = 200050;
Combi_Num cn = Combi_Num(MAX_SIZE, MOD);

int B, W;

long long no_white[MAX_SIZE], no_black[MAX_SIZE];

int main(int argc, char **argv) {
    std::cin >> B >> W;

    for (int i = 0; i < B + W; i++) {
        if (i < W) {
            no_white[i] = 0;
        } else {
            no_white[i] = no_white[i - 1] + cn.combi(i - 1, W - 1) * cn.pow_inv[i];
            no_white[i] = no_white[i] % MOD; 
        }

        if (i < B) {
            no_black[i] = 0;
        } else {
            no_black[i] = no_black[i - 1] + cn.combi(i - 1, B - 1) * cn.pow_inv[i];
            no_black[i] = no_black[i] % MOD;
        }
    }

    for (int i = 1; i <= B + W; i++) {
        if (i < B + W) {
            long long res_both = (MOD * 2 + 1 - no_black[i-1] - no_white[i-1]) % MOD;
            long long ret = (no_white[i-1] + res_both * cn.inv[2]) % MOD;
            std::cout << ret << std::endl;
        } else {
            long long ret = no_white[i-1];
            std::cout << ret << std::endl;
        }
    }

    return 0;
}

Measured memory_bytes: 13184
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N, D, Q;
int A[500011];
int val[500011];
LL bad[500011];


void MAIN() {
    scanf("%d%d", &N, &D);
    REP (i, N) scanf("%d", A+i);

    bad[N] = 1;
    for (int i=N; i--;) {
	if (A[i] < 2 * bad[i+1]) {
	    bad[i] = bad[i+1] + A[i];
	} else {
	    bad[i] = bad[i+1];
	}
    }

    val[0] = D;
    REP (i, N) {
	val[i+1] = min(val[i], abs(val[i] - A[i]));
    }

    scanf("%d", &Q);
    REP ($, Q) {
	int x;
	scanf("%d", &x);
	bool yes = (val[x-1] >= bad[x]);
	puts(yes? "YES": "NO");
    }
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a<b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a>b){a=b;}}
void YesNo(int a) {if(a){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}}
void YESNO(int a) {if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
void AorB(int a,string b,string c) {if(a){cout<<b<<endl;}else{cout<<c<<endl;}}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

signed main(){start();
    int n,x=0,y=0,z=0,ans=0;
    cin>>n;
    Vs s(n);
    REP(i,0,n){
        cin>>s[i];
        REP(j,0,s[i].size()-1) if(s[i][j]=='A' && s[i][j+1]=='B') ans++;
        if(s[i][0]=='B' && s[i][s[i].size()-1]=='A') z++;
        else if(s[i][0]=='B') y++;
        else if(s[i][s[i].size()-1]=='A') x++;
    }
    if(x>0 && y>0) ans += z+1+min(x-1,y-1);
    else if(x==0 && y==0) ans += max(0LL,z-1);
    else ans += z;
    
    cout<<ans<<endl;
    return 0;
}

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

int main(){
	int N,M;
	cin >> N >> M;
	vector<int> a(M);
	vector<int> b(M);
	for(int i=0;i<M;i++)cin >> a[i] >> b[i];
	vector<bool> c(N+1,false);
	for(int i=0;i<M;i++){
		if(a[i]==1)c[b[i]]=true;
	}
	for(int i=0;i<M;i++){
		if(b[i]==N){
			if(c[a[i]]){
				cout << "POSSIBLE" << endl;
				return 0;
			}
		}
	}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(15);
    int N, M;
    cin >> N >> M;
    for (int i = M/N; i > 0; i--) {
      if (M % i == 0) {
        cout << i << endl;
        return 0;
      }
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(long long (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (long long (i)=(a); (i)<=(b); ++(i))
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define mp make_pair
const int mx=1e5+5;

int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	ll a,b;
	ll ans=0;
	cin >> a >> b;
	long long int ar[a];
	rep(i,a){
		cin >> ar[i];
		if(ar[i]>=b)++ans;
	}
cout << ans ;
}

Measured memory_bytes: 1024
n = int(input())
s = [list(input().split()) for i in range(n)]
for i in range(n):
  s[i].append(i+1)
s.sort(key=lambda x: int(x[1]), reverse=True)
s.sort(key=lambda x: x[0])
for e in s:
  print(e[2])

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

int n, m;
int h[100001];
vector<int> adj[100001];

int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        cin >> h[i];
    }
    for (int i = 0; i < m; i++) {
        int a, b; cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        bool failed = false;
        for (int nx : adj[i]) {
            if (h[nx] >= h[i]) {
                failed = true;
                break;
            }
        }
        if (!failed) ans++;
    }

    cout << ans << '\n';

    /*
    queue<int> q;
    q.push(1);

    while (!q.empty()) {
        int x = q.front(); q.pop();

        for (int nx : adj[x]) {
            if (h[nx] >= h[x]) {

            }
        }
    }
    */

    return 0;
}


Measured memory_bytes: 9184
s = list(input())
flaga = 0
flagb = 0
for i in range(len(s)):
    if s[i] == "A":
        flaga = 1
    if s[i] == "B":
        flagb = 1

if flaga == 1 and flagb == 1:
    print("Yes")
else:
    print("No")

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

typedef pair<int, int> pair_int;

bool comp(pair_int p, pair_int q) {
    return p.second < q.second;
}

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

    int n, m;
    cin >> n >> m;
    pair<int, int> p[m];
    for (int i = 0; i < m; ++i) {
        cin >> p[i].first >> p[i].second;
    }

    sort(p, p + m, comp);

    int pos = p[0].second - 1;
    int remove = 1;
    for (int i = 0; i < m; ++i) {
        if (pos <  p[i].first) {
            remove++;
            pos = p[i].second - 1;
        }
    }

    cout << remove << '\n';

    return 0;
}


Measured memory_bytes: 1024
#At coder 2020/2/9 B

# 入力
N = int(input())
A = list(map(int, input().split())) 

if len(A)-len(set(A))==0:
    ans='YES'
else:
    ans='NO'
#ans='YES'
#for ii in range(N-1):
#    for jj in range(ii+1,N):
#        if A[ii]==A[jj]:
#            ans='NO'
#            break
#    if ans=='NO':
#        break


print(ans)

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

int main(){
	int n, m;
	cin >> n;
	map<string, int> ma;
	string s;
	rep(i, n){
		cin >> s;
		ma[s]++;
	}
	cin >> m;
	rep(i, m){
		cin >> s;
		ma[s]--;
	}
	int ans = 0;
	for(auto it = ma.begin(); it != ma.end(); ++it) {
		if(ans < it->second) ans = it->second;
	}
	cout << ans << endl;
	return 0;
}

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

#include<bits/stdc++.h>

using namespace std;

int main()
{
    int n,i,c,tot=0;
    cin>>n;
    string s[n],X;
    int t[n];
    for(i=0;i<n;i++)
    {
        cin>>s[i];
        cin>>t[i];
    }
    cin>>X;
    for(i=0;i<n;i++)
    {
        if(s[i]==X)
        {
        c=i;
        break;
        }
    }
    for(i=c+1;i<n;i++)
    {
        tot+=t[i];
    }
    cout<<tot<<endl;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  vi l(10);
  while (cin >> l[0]) {
    char gomi;
    cin >> gomi;
    loop(i, 1, 10) cin >> l[i] >> gomi;
    int u, v;
    cin >> u >> gomi >> v;
    int s    = accumulate(all(l), 0);
    double x = double(s) * u / (u + v);
    rep(i, 10) {
      x -= l[i];
      if (x <= 0) {
        cout << i + 1 << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 3120
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <bitset>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int n,m;
    cin >> n >> m;
    bool s[10][10];
    int tmp,tmp2;
    vector<int> p(m);
    
    rep(i,10){
        rep(j,10){
            s[i][j] = false;
        }
    }

    rep(i,m){
        cin >> tmp;
        rep(j,tmp){
            cin >> tmp2;
            tmp2--;
            s[i][tmp2] = true;
        }
    }

    rep(i,m){
        cin >> p[i];
    }    

    int ans = 0;

    rep(k,1 << n){

        bitset<10> bs(k);
        vector<int> on_cnt(m);
        rep(i,m){
            rep(j,n){
                if(bs[j] == 1 && s[i][j] == true){
                    on_cnt[i]++;
                }
            }
        }
        int cnt = 0;
        rep(i,m){
            if(on_cnt[i] % 2 == p[i]){
                cnt++;
            }
        }

        if(cnt == m){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n,k;
  scanf("%999d",&n);
  n = n % 10;
  if(n==3) {
    printf("bon\n");
  }else if(n==0 || n==1 || n==6 || n==8){
    printf("pon\n");
  }else {
    printf("hon\n");
  }
  return 0;
}

Measured memory_bytes: 1632
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
string s;
using MIte = multimap<int, int>::iterator;



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

	if ((S[0] == S[1] && S[2] == S[3] && S[0] != S[2]) ||
		(S[0] == S[2] && S[1] == S[3] && S[0] != S[1]) ||
		(S[0] == S[3] && S[1] == S[2] && S[0] != S[1])) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int k = sc.nextInt();
		
		int maxab = Math.max(a, b);
		int max = Math.max(c, maxab);
		
		int max2 = max;
		
		for (int i = 0; i < k; i++){
			max2 *= 2;
		}
		
		System.out.println(max2 + a + b + c - max);
	}
}

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

def main():
    n = int(input())
    seat_list = []
    for _ in range(n):
        seat_list.append(list(map(int, input().split())))
    ans = 0

    for i in seat_list:
        ans += i[1] - i[0] + 1

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n][3];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>a[i][j];
        }
    }
    vector<vector<int>> dp(n,vector<int>(3));
    for(int i=0;i<3;i++)
    {
        dp[0][i]=a[0][i];
    }
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            if(j==0)
            {
                dp[i][j]=max(dp[i-1][1],dp[i-1][2])+a[i][j];
            }
            else if(j==1)
            {
                dp[i][j]=max(dp[i-1][0],dp[i-1][2])+a[i][j];
            }
            else if(j==2)
            {
                dp[i][j]=max(dp[i-1][0],dp[i-1][1])+a[i][j];
            }
        }
    }
    cout<<*max_element(dp[n-1].begin(),dp[n-1].end());
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N = nextInt();
  ll ans = 0;
  int max_p = 0;
  REP(i, N) {
    int p = nextInt();
    ans += p;
    chmax(max_p, p);
  }
  ans -= max_p / 2;
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>


template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;


int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/

	int n, u, v, m; cin >> n >> u >> v >> m;
	map<int, pair<int, int>> up, vp;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			int x; cin >> x;
			up[x] = { i,j };
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			int x; cin >> x;
			vp[x] = { i,j };
		}
	}
	vector<int> uv(n), uc(n), vv(n), vc(n);
	int u1 = 0, u2 = 0, v1 = 0, v2 = 0;
	int ucnt = 0, vcnt = 0;
	for (int i = 0; i < m; i++) {
		int x; cin >> x;
		if (up.count(x)) {
			int h, w; tie(h, w) = up[x];
			uv[h]++; if (uv[h] == n) ucnt++;
			uc[w]++; if (uc[w] == n) ucnt++;
			if (h == w) { u1++; if (u1 == n) ucnt++; }
			if (h + w == n - 1) { u2++; if (u2 == n) ucnt++; }
		}
		if (vp.count(x)) {
			int h, w; tie(h, w) = vp[x];
			vv[h]++; if (vv[h] == n) vcnt++;
			vc[w]++; if (vc[w] == n) vcnt++;
			if (h == w) {v1++; if (v1 == n) vcnt++; }
			if (h + w == n - 1) { v2++; if (v2 == n) vcnt++; }
		}
		if (n == 1) chmin(ucnt, 1), chmin(vcnt, 1);
		if (ucnt >= u and vcnt >= v) {
			cout << "DRAW" << endl;
			return 0;
		}
		else if (ucnt >= u) {

			cout << "USAGI" << endl;
			return 0;
		}
		else if (vcnt >= v) {
			cout << "NEKO" << endl;
			return 0;
		}
	}
	cout << "DRAW" << endl;
	return 0;
}




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

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

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>void add(T &a, const T &b){a += b; a %= mod;}

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

  int a = 0;
  double b = 0;
  rep(i,n){
    string x; cin >> x;
    string u; cin >> u;
    if(u == "JPY") a += stoll(x);
    else b += stod(x);
  }
  dump(a,b);
  cout << a + b * 380000 << endl;
}


Measured memory_bytes: 256
N, M = map(int,input().split())
ps = [list(map(str,input().split())) for i in range(M)]

er_c = 0
ac_c = 0

if M == 0:
    print(0, 0)
    exit(0)

flag = [0]*N

for i in reversed(range(M)):
    if ps[i][1] == 'AC':
        flag[int(ps[i][0])-1] = 1

for i in range(M):
    if flag[int(ps[i][0])-1] == 1:
        if i == 0:
            if ps[i][1] == 'WA':
                er_c += 1
            else:
                ac_c += 1
                flag[int(ps[i][0])-1] = -1
        elif ps[i][1] == 'WA':
            er_c += 1
        elif ps[i][1] == 'AC':
                ac_c += 1
                flag[int(ps[i][0])-1] = -1

print(ac_c, er_c)

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

int main() {
  char c;
  cin >> c;

  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
n,x=gets.split.map(&:to_i)

m = 1
p = 1
LMAP = [1]
PMAP = [1]
n.times do
  m = 3 + m * 2
  p = 1 + p * 2
  LMAP << m
  PMAP << p
end

def count(l, a)
  return 0 if a == 0
  if l == 1
    return 3 if a == 5
    return a - 1
  end

  center = LMAP[l-1] + 1

  if a < center
    count(l-1,a-1)
  elsif a == center
    PMAP[l-1]
  elsif a == center + 1
    PMAP[l-1] + 1
  elsif a == LMAP[l]
    PMAP[l]
  else # a > center + 1
    PMAP[l-1] + 1 + count(l-1,a-(center+1))
  end
end

p count(n,x)


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(x) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  int N,K;
  while(cin >> N >> K){
    cout << N-K+1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import math

N = int(input())
data = list(map(int,input().split()))


BIG = pow(10,9)+7

dp = [BIG]*(N+1)

dp[0] = 0

for i in range(N):
    for j in range(i+1,i+3):
        if j<N:
            dp[j] = min(dp[j], dp[i] + abs(data[i]-data[j]))
            
print(dp[N-1])


Measured memory_bytes: 14484
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

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

int extgcd(int a, int b, int& x, int& y) {
	int d = a;
	if(b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	 } else {
		 x = 1; y = 0;
	 }
	return d;
}

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

	int N;
	cin >> N;
	ll T[N];
	rep(i, 0, N) cin >> T[i];

	ll rsl = T[0];
	rep(i, 0, N) rsl = lcm(rsl, T[i]);

	cout << rsl << endl;

}


Measured memory_bytes: 256
#include<cstdio>

using namespace std;

void trace(int a[],int N){
    int i;
    for(i=0;i<N;++i){
        if(i>0) printf(" ");
        printf("%d",a[i]);
    }
    printf("\n");
}

void insertSort(int* addr, int N){
    int j,i,v;
    for(i=1;i<N;++i){
        v=addr[i];
        j=i-1;
        while(j>=0 && addr[j]>v){
            addr[j+1]=addr[j];
            --j;
        }
        addr[j+1]=v;
        trace(addr,N);
    }
    return;
}


int main(void){
    int N,i,j;
    int addr[100];
    scanf("%d",&N);
    for(i=0;i<N;++i){
        scanf("%d",addr+i);
    }
    trace(addr,N);
    insertSort(addr,N);
    return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  long long mod = 1000000007, result = 1;
  if (fabs(n - m) > 1) {
    result = 0;
  } else {
    int i;
    for (i = 1; i <= n; i++) {
      result *= i % mod;
      result %= mod;
    }
    for (i = 1; i <= m; i++) {
      result *= i % mod;
      result %= mod;
    }
    if (n == m) {
      result *= 2;
    }
    result %= mod;
  }
  cout << result << endl;
  return 0;
}


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

using namespace std;
using ll = long long;

int main(){
	ios_base::sync_with_stdio(false);
	ll a, b, c, d, n;
	cin >> a >> b >> c >> d >> n;
	a *= 4;
	b *= 2;
	ll answer = 0;
	if(d < a * 2 && d < b * 2 && d < c * 2){
		answer = (n / 2) * d;
		n %= 2;
	}
	answer += min({ a, b, c }) * n;
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int D; cin >> D;
    cout << "Christmas";
    rep(i, 25 - D) {
        cout << " Eve";
    }
    cout << endl;



    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;

int main(){
    int N, sum=0;
    cin >> N;
    vector<int> H(N);
    for(int i = 0; i < N; i++){
        cin >> H[i];
        sum = max(H[i], sum);
    }
    int ans = 0;
    for(int i = 1; i <= sum; i++){
        bool flag = false;
        for(int j = 0; j < N; j++){
            if(H[j] >= i) flag = true;
            else{
                if(flag) ans++;
                flag = false;
            }
        }
        if(flag) ans++;
    }
    cout << ans << endl;
}

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

using namespace std;

int main(){
  int a,b,c; cin >> a >> b >> c;
  int ct = 0;
  while(a%2 == 0 && b%2 == 0 && c%2 == 0){
    int x = (a+b)/2;
    int y = (b+c)/2;
    int z = (c+a)/2;
    a = x; b = y; c = z;
    ct++;
    //cout << a << " " << b << " " << c << "!!\n";
    if(a == b && b == c){
      cout << -1 << "\n";
      return 0;
    }
  }
  cout << ct << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
#define MOD 1000000007
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int n,m,G[15],bul[1<<15],bin[25],f[1<<15];
int main()
{
	n=read();m=read();
	for(int i=1,u,v;i<=m;++i)u=read()-1,v=read()-1,G[u]|=1<<v;
	int N=(1<<n)-1;f[0]=1;
	for(int i=1;i<=N;++i)bul[i]=bul[i>>1]+(i&1);
	bin[0]=1;for(int i=1;i<=n;++i)bin[i]=(bin[i-1]<<1)%MOD;
	for(int i=2;i<=N;++i)
		if((i&1)==((i>>1)&1))
			for(int U=i;U;U=(U-1)&i)
				if((U&1)==((U>>1)&1))
				{
					int T=i^U,w=1;
					for(int j=0;j<n;++j)
						if(i&(1<<j))
						{
							if(U&(1<<j))w=1ll*w*bin[bul[G[j]&T]]%MOD;
							else w=1ll*w*(bin[bul[G[j]&U]]-1)%MOD;
						}
					f[i]=(f[i]+1ll*f[T]*w)%MOD;
				}
	int ans=1;for(int i=1;i<=m;++i)ans=(ans<<1)%MOD;
	ans=(ans+MOD-f[N])%MOD;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 512
#include <iostream>

int main(int argc, char const *argv[])
{
    int a, b, c;

    std::cin >> a >> b >> c;

    if (a < b && b < c)
    {
        std::cout << "Yes" << std::endl;
    }
    else
    {
        std::cout << "No" << std::endl;
    }

    return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using graph = vector<vector<int>>;
using wgraph = vector<vector<pair<int, lint>>>;
const lint INF = 1001001001001001LL;
const lint MOD = 1000000007LL;
const double PI = 3.1415926535897932;
int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

void yes(){ cout << "yes" << endl; }
void Yes(){ cout << "Yes" << endl; }
void YES(){ cout << "YES" << endl; }
void no(){ cout << "no" << endl; }
void No(){ cout << "No" << endl; }
void NO(){ cout << "NO" << endl; }
void possible(){ cout << "possible" << endl; }
void Possible(){ cout << "Possible" << endl; }
void POSSIBLE(){ cout << "POSSIBLE" << endl; }
void impossible(){ cout << "impossible" << endl; }
void Impossible(){ cout << "Impossible" << endl; }
void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#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 srep(i,s,t) for(int i = s; i < t; i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()


int main(){
   
  int M, D; cin >> M >> D;
  lint ans = 0;
  for(lint m = 1; m <= M; m++){
    for(lint d = 10; d <= D; d++){
      lint d1 = d % 10;
      lint d2 = d / 10;
      if(d1 >= 2 and d2 >= 2 and d1 * d2 == m) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int max(int x,int y){return (x<y)?y:x;}
int main(){
  int n,a,b,c,da=0,db=0,dc=0,ta,tb,tc;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d%d%d",&a,&b,&c);
    ta=da;
    tb=db;
    tc=dc;
    da=max(tb+a,tc+a);
    db=max(ta+b,tc+b);
    dc=max(ta+c,tb+c);
  }
  printf("%d",max(da,max(db,dc)));
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>
#include <fstream>
#include <ctime>

using namespace std;
using ll = long long;

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

template <class T>
std::vector<T> enum_div(T n) {
    std::vector<T> ret;
    for (T i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

bool isPrime(ll num) {
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;


    for (ll i = 3; i * i <= num; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
};


template<typename T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool is_integer(T x) {
    return std::floor(x) == x;
}

struct ToUpper {
    char operator()(char c) { return toupper(c); }
};

struct ToLower {
    char operator()(char c) { return tolower(c); }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    string S;
    cin >> N >> S;
    if (N % 2 == 1) {
        cout << "No" << endl; return 0;
    }
    string T, U;
    T = S.substr(0, N / 2);
    U = S.substr(N / 2, N / 2);
    YESNO(T == U, "Yes", "No");
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int K; cin >> K;
    ll ans = 0;
    for (ll i = 1; i <= K; i++) {
        for (ll j = 1; j <= K; j++) {
            for (ll k = 1; k <= K; k++) {
                ll val = __gcd(i,j);
                val = __gcd(val,k);
                ans += val;
            }
        }
    }

    cout << ans << ln;
}

Measured memory_bytes: 3688