akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;


int main()
{
    lint H;
    cin >> H;
    lint W;
    cin >> W;
    lint h;
    cin >> h;
    lint w;
    cin >> w;
    cout << (H - h) * (W - w) << endl;
    return 0;
}


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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  for (int i = 0; i < 5; i++){
    int a;
    cin >> a;
    if (a == 0){
      cout << i +1;
    }
  }
  return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include<math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


int main() {
	int X, Y, Z;
	cin >> X >> Y >> Z;
	int A = 0;
	int B = 0;

	A = X;
	B = Y;

	Y = A;
	X = B;


	A = X;
	B = Z;

	Z = A;
	X = B;

	cout << X << " " << Y << " " << Z << endl;
	
return 0;
} 

Measured memory_bytes: 256
from bisect import bisect_left,bisect_right
N = int(input())
A = sorted(list(map(int,input().split())))
G = {i:0 for i in range(10**5)}
cntmax = 0
for i in range(10**5):
    ind0 = bisect_left(A,i-1)
    ind1 = bisect_right(A,i+1)
    cntmax = max(cntmax,ind1-ind0)
print(cntmax)   
    

Measured memory_bytes: 20544
#include <iostream>

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

    int n;

    while (std::cin >> n) {
        int ans = 2;
        for (int i = 2; i <= n; ++i) {
            ans += i;
        }
        std::cout << ans << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1192
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
const int inf = 1e9;
const int mod = 2019;

int main() {
    int L, R;
    cin >> L >> R;
    if (L == 0) {
        cout << 0 << endl;
        return 0;
    }

    ll x = mod;
    while (x <= R) {
        if (L <= x && x <= R) {
            cout << 0 << endl;
            return 0;
        }
        x += mod;
    }


    int ans = 1e9;
    for (int i = L; i <= R; i++) { 
        for (int j = i+1; j <= R; j++) {
            ll x = (ll)i * (ll)j;
            x %= mod;
            if (x < ans) ans = x;
        }
    }

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


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

using namespace std;

int main() {
	char a;
	cin >> a;
	if (a >= 'A' && a <= 'Z') {
		cout << 'A';
	}
	else if (a >= 'a' && a <= 'z') {
		cout << 'a';
	}
	cout << endl;
	return 0;
}

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

int N,M,K;
int E[100],A[100];
int v[4];

double dp[51][5000];
void solve(){


    dp[0][0]=1.0;
    for(int i=0;i<N;i++){
        for(int j=N-1;j>=i;j--){
            for(int k=0;k<=i*100;k++){
                if(dp[j][k]<(1e-9))continue;
                for(int l=0;l<M;l++){
                    int toval=k;
                    int topos=min(N,j+v[l]);
                    if(E[topos]==1)topos=min(N,topos+A[topos]);
                    else if(E[topos]==2)toval+=A[topos];
                    else if(E[topos]==3)toval=max(0,toval-A[topos]);
                    dp[topos][toval]+=dp[j][k]/M;
                }
                dp[j][k]=0;
            }

        }
    }

    double sum=0;
    for(int i=0;i<5000;i++)sum+=dp[N][i]*i;
    cout<<(int)sum<<endl;
}

bool input(){
    for(int i=0;i<51;i++){
        for(int j=0;j<5000;j++)dp[i][j]=0;
        E[i]=A[i]=0;
    }

    cin>>M>>N>>K;
    if(M==0&&N==0&&K==0)return false;
    for(int i=0;i<M;i++)cin>>v[i];
    for(int i=0;i<K;i++){
        int n,e,a;
        cin>>n>>e>>a;
        E[n]=e;
        A[n]=a;
    }
    return true;
}

int main(){
    while(input())solve();
    return 0;
}

Measured memory_bytes: 3152
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll MOD=1000000007;
int main(){
  ll a,v,b,w,t;cin>>a>>v>>b>>w>>t;
  bool ok=true;
  if(abs(b-a)>(v-w)*t)ok=false;
  if(!ok)cout << "NO" << endl;
  else cout << "YES" << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N, 0);
    int sum = 0;
    for (int i = 0; i < N; ++i) {
        cin >> A[i]; sum += A[i];
    }
    int cnt = 0;
    double F = sum * (1 / (4.0 * M));
    for (int i = 0; i < N; ++i) {
        if (A[i] >= F) cnt++;
    }
    if (cnt >= M) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n); std::vector<int> a(n);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	
	std::vector<int> A(n + 1, 0);
	for(int i = 0; i < n; i++) A[i + 1] = std::max(A[i], a[i]);
	
	int tmp = 0;
	std::vector<int> ans;
	for(int i = n - 1; i >= 0; i--) {
		ans.push_back(std::max(A[i], tmp));
		tmp = std::max(tmp, a[i]);
	}
	reverse(begin(ans), end(ans));
	for(auto v: ans) printf("%d\n", v);
	return 0;
}


Measured memory_bytes: 4084
dic = {}
ans = []
a = 0

N = int( input() )
for i in range( N ):
  let = input()
  if let not in dic:
    dic.update( { let : 1 } )
  else:
    num=dic[ let ]
    dic[ let ] = num + 1
dic_sorted = sorted(dic.items(), key=lambda x:x[1],reverse=True)
for each in dic_sorted:
  if each[1] >= a:
    ans.append(each[0])
    a=each[1]
  else:
    break
ans.sort()
for each in ans:
  print(each)

Measured memory_bytes: 45788
#include <stdio.h>
int main(void){
  int a[3],min,i,res,mini;
  int b[3];
  scanf("%d %d %d",&a[0],&a[1],&a[2]);
  b[0] = a[0]+a[1];
  b[1] = a[0]+a[2];
  b[2] = a[1]+a[2];
  min = b[0];
  for(i=0;i<=2;i++){
    if(min > b[i]){
      min = b[i];
    }
  }
  printf("%d\n",min);
  return 0;
}

Measured memory_bytes: 128
#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
#define int long long 
int F[2100010];

int Mul(int a, int b) {
	return ((a % mod) * (b % mod)) % mod;
}

void fact(void) {
	F[0] = 1;
	F[1] = 1;
	for (int i = 2; i <= 2100000; i++) {
		F[i] = Mul(i, F[i - 1]);
	}
}
int square(int x) {
	return (x * x) % mod;
}

int power(int x, int y) {
	if (y == 0) return 1;
	else if (y == 1) return x % mod;
	else if (y % 2 == 0) return square(power(x, y / 2)) % mod;
	else return square(power(x, y / 2)) * x % mod;
}

int Div(int a, int b) {
	return Mul(a, power(b, mod - 2));
}
int P(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return Div(F[n], F[n - r]);
}

int C(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	int ret;
	ret = Div(F[n], Mul(F[n - r], F[r]));
	return ret;
}
int H(int n, int r) {
	if (n == 0 && r == 0) return 1;
	return C(n + r - 1, r);
}

vector<int> T[100010];
int N, K;
int dfs(int x, int p = -1) {
    int ret = 1;
    int cnt = K - 1;
    if(p >= 0) cnt--;
    for(auto to: T[x]) {
        if (to == p) continue;
        ret = Mul(Mul(ret, dfs(to, x)), cnt);
        cnt--;
    }
    return ret;

} 

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N >> K;
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        T[a].push_back(b);
        T[b].push_back(a);
    }
    fact();
    cout << Mul(dfs(0), K) << endl;

    return 0;
}


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

int main() {

    int h, n, a;
    scanf("%d %d", &h, &n);

    int mysum = 0;

    for (int i = 0; i < n; i++) {
        scanf("%d", &a);
        mysum += a;
        if(mysum>=h){
            printf("Yes");
            return 0;
        }
    }

    printf("No");

    
    return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
    int H,W;
    cin>>H>>W;
    char M[52][52]={'.'};
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>M[i+1][j+1];
        }
    }

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(M[i][j+1]=='.' and M[i+2][j+1]=='.' and M[i+1][j]=='.' and M[i+1][j+2]=='.' and M[i+1][j+1]=='#') {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

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

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

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

fn main() {
    input! {
        s: chars,
    }
    for _ in s { print!("x"); }
    println!();
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};

int main(){
  int n; cin >> n;
  ll num[10][10];
  memset(num, 0, sizeof(num));
  for(int i = 1; i < n+1; i++) {
    string s = to_string(i);
    int a = s[0]-'0';
    int b = s.back()-'0';
    //printf("%d %d\n", a, b);
    num[a][b]++;
  }
  ll ans = 0;
  for(int i = 1; i < 10; i++) {
    for(int j = 1; j < 10; j++) {
      ans += num[i][j]*num[j][i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

using namespace std;

#define FOR(a,b) for(int a=0;a<b;a++)
#define F0R(a,b,c) for(int a = b; a<=c; a++)
#define f first
#define s second
#define m0(x) memset(x,0,sizeof(x))

typedef pair<int,int> pi;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pi> vpi;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int x,y,z; cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
    return 0;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define INF LONG_LONG_MAX
#define MOD 1000000007
#define yn(f) cout << (f ? "Yes" : "No") << endl;
#define YN(f) cout << (f ? "YES" : "NO") << endl;

int n,k,cnt[100];

signed main() {
    cin >> n >> k;
    rep(i,k) {
        int d;
        cin >> d;
        rep(j,d) {
            int a;
            cin >> a;
            --a;
            cnt[a]++;
        }
    }
    int ans=0;
    rep(i,n) if (cnt[i] == 0) ans++;
    cout << ans << endl;
}




Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp>>;

const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

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

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);
  int n;
  cin >> n;
  string s;
  cin >> s;
  for (auto &&c : s)
  {
    c += n;
    if (c > 'Z')
      c -= 26;
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
inline ll lin() { ll x; scanf("%lld",&x); return x;}
inline char chin() { char x; scanf("%c",&x); return x;}
inline string stin() { string x; cin >> x; return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
char itoa(int n) { return n + '0';}
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int n = in();
  vi r(n);
  rep(i,n) cin >> r[i];
  int maxv = -INF;
  int minv = r[0];
  srep(j,1,n) {
    maxv = max(maxv, r[j]-minv);
    minv = min(minv, r[j]);
  }
  cout << maxv << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	ll N, M;
	cin >> N >> M;
	if (abs(N - M) > 1) {
		cout << 0 << endl;
		return 0;
	}
	ll ans = 1;
	for (int i = 1; i <= N; i++) ans = (ans * i) % mod;
	for (int i = 1; i <= M; i++) ans = (ans * i) % mod;
	if (N - M == 0) cout << (ans * 2) % mod << endl;
	else cout << ans % mod << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;


int main()
{
    int a,b;
    cin >> a >> b;
    if(a<=8 && b<=8)
        cout << "Yay!" << endl;
    else
        cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
use std::cmp::*;
use std::io::*;
use std::str::FromStr;

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")
}

fn main() {
    let a: isize = read();
    let b: isize = read();

    let ans = max(a + b, max(a - b, a * b));
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;


int main() {
  int n,a,b;
  cin >> n >> a >> b;
  if (a%n == 0) {
    cout << "OK" << endl;
    return 0;
  }
  else if (b >= (a/n + 1)*n) {
    cout << "OK" << endl;
    return 0;
  }
  else cout << "NG" << endl;

}


Measured memory_bytes: 3132
'''
N, M = map(int, input().split())
A = list(list(input()) for _ in range(N))
B = list(list(input()) for _ in range(M))

ans = 'No'
d = N - M + 1
for i in range(d):
    for j in range(d):
        cnt = 0
        for x in range(M):
            if A[i+x][j:j+M+1] == B[x]:
                cnt += 1
            else:
                break
        if cnt == M:
            ans = 'Yes'
            break
    if ans == 'Yes':
        break

print(ans)
'''
N, M = map(int, input().split())
A = list(list(input()) for _ in range(N))
B = list(list(input()) for _ in range(M))

ans = 'No'
d = N - M + 1
for i_a in range(d):
    for j_a in range(d):
        cnt = 0
        for i_b in range(M):
            for j_b in range(M):
                if A[i_a + i_b][j_a + j_b] == B[i_b][j_b]:
                    cnt += 1
                else:
                    break
            
        if cnt == M**2:
            ans = 'Yes'
            break
    if ans == 'Yes':
        break

print(ans)


Measured memory_bytes: 3064
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cmath>

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

int main() {
	long long N;
	cin >> N;

	vector<long long> h;

	long long Nsqrt = static_cast<long long>(ceil(sqrt(static_cast<long long> (N))));
	for (long long i = 1; i <= Nsqrt; i++) {
		if (N % i == 0) {
			h.emplace_back(i);
		}
	}

	long long hoge = h.back();
	if (hoge != 1) {
		hoge = N / hoge - 1 + hoge - 1;
	}
	else {
		hoge = N / hoge - 1;
	}

	cout << hoge << endl;
}

Measured memory_bytes: 256
n, q = gets.chomp.split(' ').map(&:to_i)
arr = []
(0...n).each do |i|
  arr[i]= gets.chomp.split(' ')
end

class Queue
  attr_accessor :head, :tail, :queue

  def initialize(size)
    @head = 0
    @tail = 0
    @queue = Array.new(size)
  end

  def enqueue(x)
    @queue[@tail] = x
    if @tail + 1 == @queue.size
      @tail = 0
    else
      @tail += 1
    end
  end

  def dequeue
    x = @queue[@head]
    if @head + 1 == @queue.size
      @head = 0
    else
      @head += 1
    end
    return x
  end

  def isEmpty?
    return @head == @tail
  end

  def isFull?
    return @head == (@tail + 1) % @queue.size
  end
end

queue = Queue.new(n + 1)
time = 0

(0...n).each do |i|
  queue.enqueue(arr[i])
end

while !queue.isEmpty?
  process = queue.dequeue
  if process[1].to_i > q
    process[1] = process[1].to_i - q
    time += q
    queue.enqueue(process)
  else
    time += process[1].to_i
    print "#{process[0]} #{time}\n"
  end
end



Measured memory_bytes: 15752
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int A[110];
int main()
{
	int K, T;
	cin >> K >> T;
	for (int i = 0; i < T; i++) cin >> A[i];
	sort(A, A + T, greater<int>());
	int ans = A[0] - 1;
	for (int i = 1; i < T; i++) {
		ans -= A[i];
	}
	cout << max(0, ans) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int h,w;
char mm1[500][500];
char mm2[500][500];
int main(){
    while(scanf("%d%d",&h,&w) != EOF){
        getchar();
        for(int i = 1;i <= h;++i) {
            for(int j = 1;j <= w;++j){
                scanf("%c",&mm1[i][j]);
            }getchar();
        }
        for(int i = 1;i <= 2*h;++i){
            for(int j = 1;j <= w;++j){
                mm2[i][j] = mm1[(i+1)/2][j];
            }
        }
      //  printf("---\n");
        for(int i = 1;i <= 2*h;++i){
            for(int j = 1;j <= w;++j){
                printf("%c",mm2[i][j]);
            }printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int N;
    cin >> N;
    vector<ll> P(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> P[i];
    }
    int ans = 0;
    for ( int i = 0; i < N-2; i++ ) {
        if ( P[i] <= P[i+1] && P[i+1] <= P[i+2] ) ans++;
        else if ( P[i] >= P[i+1] && P[i+1] >= P[i+2]) ans++;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MOD=1e9+7;
int add(int a,int b){
	return a+b>=MOD?a+b-MOD:a+b;
}
int sub(int a,int b){
	return a-b>=0?a-b:a-b+MOD;
}
void dadd(int &a,int b){
	a=add(a,b);
}
int mul(int a,int b){
	return (LL)a*b%MOD;
}
const int N=5050;
int f[N][N+1]={0};
int g[N][N+1]={0};
int h[N][N+1]={0};
int main(){
	ios::sync_with_stdio(false);
	int n,a,b;
	cin>>n>>a>>b;
	if(a>b)swap(a,b);
	f[n+1][b]=1;
	g[n+1][b]=1;
	h[n+1][b]=1;
	for(int i=n;i>=1;i--){
		for(int j=0;j<b-1;j++){
			int &ans=f[i][j];
			ans=f[i+1][min(j+1,b)];
			dadd(ans,h[i+2][0]);
			int s=i+a+1;
			if(s<=n+1){
				dadd(ans,sub(0,h[s][0]));
				int t=max(s-1,min(b+i-j,n+1))+1;
				dadd(ans,g[s][j-i+s]);
				if(t<=n+1){
					dadd(ans,g[t][j-i+t]);
					dadd(ans,h[t][b]);
				}
			}
		}
		for(int j=b-1;j<=b;j++){
			f[i][j]=h[i+1][b];
		}
		for(int j=0;j<=b;j++){
			g[i][j]=add(g[i+1][j+1],f[i][j]);
		}
		for(int j=0;j<=b;j++){
			h[i][j]=add(h[i+1][j],f[i][j]);
		}
	}
	int ans=0;
	for(int k=0;k+1<=n+1;k++){
		dadd(ans,f[k+1][k>=a?min(k,b):0]);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 299680
#include<cstdio>
#include<cstring>
using namespace std;
#define MAXN 10
char s[MAXN];
int ans=0;
long long a=0;
int main()
{
	scanf("%s",s);
	int lens=strlen(s);
	for(int i=0;i<lens;i++)
	{
		ans+=int (s[i]-48);
		if(i!=0) a*=10;
		a+=int (s[i]-48);
	}
	if(a%ans==0) printf("Yes\n");
	else printf("No\n");
}

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

using namespace std;

bool isAllowed(vector<int> &a) {
  bool entry = true;
  for (int i = 0; i < (int)a.size(); i++) {
    if (a[i] % 2) continue;
    if (!(a[i] % 3 == 0 or a[i] % 5 == 0)) {
      entry = false;
      break;
    }
  }
  return entry;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  isAllowed(a) ? cout << "APPROVED\n" : cout << "DENIED\n";
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())
a = list(map(int, input().split()))

def factorize(n):
    i = 2
    prime_factors = {}
    while i ** 2 <= n:
        exp = 0
        while n % i == 0:
            exp += 1
            n //= i
        if exp:
            prime_factors[i] = exp
        i += 1
    if n != 1:
        prime_factors[n] = 1
    return prime_factors

ans = 0
for v in a:
    prime_factors = factorize(v)
    if 2 in prime_factors:
        ans += prime_factors[2]
print(ans)


Measured memory_bytes: 74348
//----------------------------------------------------------------
//F

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

const long long INF = 1LL<<60;

// 入力
string s, t;

// DPテーブル
int dp[3100][3100] = {0}; // 初期値も初期条件も 0

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

    // DPループ
    for (int i = 0; i < s.size(); ++i) {
        for (int j = 0; j < t.size(); ++j) {
            if (s[i] == t[j]) { dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1);}
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j]);
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1]);
        }
    }

    // 復元
    string res = "";
    int i = (int)s.size(), j = (int)t.size();
    while (i > 0 && j > 0)
    {
        // (i-1, j) -> (i, j) と更新されていた場合
        if (dp[i][j] == dp[i-1][j]) {
            --i; // DP の遷移を遡る
        }

        // (i, j-1) -> (i, j) と更新されていた場合
        else if (dp[i][j] == dp[i][j-1]) {
            --j; // DP の遷移を遡る
        }

        // (i-1, j-1) -> (i, j) と更新されていた場合
        else {
            res = s[i-1] + res; // このとき s[i-1] == t[j-1] なので、t[j-1] + res でも OK
            --i, --j; // DP の遷移を遡る
        }
    }
    cout << res << endl;
}



Measured memory_bytes: 40008
from collections import defaultdict

H, W, N = map(int, raw_input().split())
X = [map(int, raw_input().split()) for _ in xrange(N)]

d = defaultdict(int)
ans = [0 for _ in range(10)]

for a, b in X:
    for ax in [-1, 0, 1]:
        for bx in [-1, 0, 1]:
            d[(a+ax, b+bx)] += 1
for k in d:
    a, b = k
    if 1 < a < H and 1 < b < W:
        ans[d[k]] += 1

ans0 = (H-2) * (W-2) - sum(ans)
ans[0] = ans0
for x in ans:
    print x


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if (abs(a - c) <= d) {
    cout << "Yes" << endl;
  } else if (abs(a - b) <= d && abs(b - c) <= d) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)
#define rep1(i,n) for(ll i=1; i<=n; ++i)
#define revrep(i,n) for(ll i=n-1; n>=0; --i)
inline constexpr ll Inf = (1ULL << 62) -1;
#define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false);
#define endl '\n'
template <class T> bool updmax(T& a, T b) { if (b > a) { a = b; return true;} return false;}
template <class T> bool updmin(T& a, T b) { if (b < a) { a = b; return true;} return false;}

int main() {
    fastio;
    ll ans=0;
    ll N;
    cin >> N;
    map<pair<int,int>,int> m;
    rep1(i,N) {
        auto s = to_string(i);
        m[{s.front(), s.back()}]++;
    }
    for (auto& [k,c] : m) {
        ans += c * m[{k.second, k.first}];
    }
    cout << ans << endl;
}


Measured memory_bytes: 3680
#include <cstdio>
#include <iostream>

using namespace std;

const int MAXN = 1010;
const int MOD = 1e9+7;

int n, m, a[MAXN][MAXN];
int f[MAXN][MAXN];
char s[MAXN];

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",s+1);
		for(int j=1;j<=m;j++)
		{
			a[i][j] = s[j] == '.';
		}
	}
	f[1][1] = 1;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(i==1 && j==1) continue;
			if(a[i][j]) f[i][j] = (f[i-1][j] + f[i][j-1])%MOD;
		}
	}
	printf("%d\n",f[n][m]);
	return 0;
}

Measured memory_bytes: 8192
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    int ans = 0;
    for (int i = 1; i <= b-a; i++) ans += i;
    cout << ans-b << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.lang.Math.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int C = scanner.nextInt();

        for (int i = 1; i <= 100; i++ ) {
            if ((A * i) % B == C) {
                System.out.println("YES");
                return;
            }
        }
        System.out.println("NO");
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";

        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String line = br.readLine();
            while (line.equals("")) {
                line = br.readLine();
            }
            s = line.split(reg, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() {
            try {
                return Integer.parseInt(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }

        public double nextDouble() {
            try {
                return Double.parseDouble(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }

        public long nextLong()  {
            try {
                return Long.parseLong(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }
    }
}


Measured memory_bytes: 23124
n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(m)]
l = []
for i in ab:
    a, b = i[0], i[1]
    if h[a - 1] <= h[b - 1]:
        l.append(a)
    if h[a - 1] >= h[b - 1]:
        l.append(b)
print(n - len(set(l)))

Measured memory_bytes: 34780
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a, b;
    cin >> a >> b;
    if (a.length() > b.length())
    {
        cout << "GREATER" << endl;
        return 0;
    }
    else if (a.length() < b.length())
    {
        cout << "LESS" << endl;
        return 0;
    }
    if (a > b)
    {
        cout << "GREATER" << endl;
    }
    else if (a == b)
    {
        cout << "EQUAL" << endl;
    }
    else
    {
        cout << "LESS" << endl;
    }
}

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

signed main(){
  lint N; cin >> N;
  vector<vector<lint> > open(N, vector<lint> (10));
  for(lint i = 0; i < N; i++){
    for(lint j = 0; j < 10; j++) cin >> open[i][j];
  }
  vector<vector<lint> > profit(N, vector<lint> (11));
  for(lint i = 0; i < N; i++){
    for(lint j = 0; j < 11; j++) cin >> profit[i][j];
  }
  lint ans = -1e18;
  for(lint bit = 1; bit < (1 << 10); bit++){
    lint ans1 = 0;
    for(lint j = 0; j < N; j++){
      lint counter = 0;
      for(lint k = 0; k < 10; k++){
        if((bit & (1 << k)) && open[j][k]) counter++;
      }
      ans1 += profit[j][counter];
    }
    ans = max(ans, ans1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;
vector<ll> adj[100009];
bool vis[100009];
ll dp[100009][2];
ll n;

pair<ll,ll> fun(ll v)
{
  if(vis[v])
  return mp(dp[v][0],dp[v][1]);
  vis[v]=1;

  for(auto u:adj[v] )
    if(!vis[u])
    {
      pair<ll,ll> p=fun(u);
      dp[v][0]=(dp[v][0]*p.ss)%mod;
      dp[v][1]=(dp[v][1]*(p.ff+p.ss))%mod;
    }
    return mp(dp[v][0],dp[v][1]);
}

int main()
{
    fast;   
   ll x,y;
   cin>>n;

   if(n==1)
   { cout<<2<<endl;
    return 0;
  }
   
   for(ll i=0;i<n;i++)
   {
    cin>>x>>y;
    adj[x-1].pb(y-1);
    adj[y-1].pb(x-1);
   }

   memset(vis,0,sizeof(vis));
   for(ll i=0;i<n+1;i++)
    dp[i][0]=dp[i][1]=1;
   fun(0);
   cout<<(dp[0][0]+dp[0][1])%mod<<endl;
  }

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

using namespace std;

typedef long long ll;

void solve(){
    int n;
    cin >> n;
    vector<int> a(n+1, 0);
    for(int i=1, x; i<n; i++){
        cin >> x;
        a[x]++;
    }
    for(int i=1; i<=n; i++)
        cout << a[i] << '\n';
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t =1, i = 1;
    //cin >> t;
    while(t--){
        solve();
        ++i;
    }
    return 0;
}


Measured memory_bytes: 3996
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <vector>

using namespace std;

vector<vector<char>> maze;

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

const long long LINF = 1000000000000000018LL;
int dx[] = {-1, 0, 0, 1};
int dy[] = {0, -1, 1, 0};

std::vector<std::vector<long long>>
dijkstra(int sx, int sy, std::vector<std::vector<char>> &G) {
  const long long LINF = 1000000000000000018LL;
  const int dx[4] = {1, -1, 0, 0};
  const int dy[4] = {0, 0, 1, -1};

  int H = (int)G.size();
  int W = (int)G[0].size();

  std::vector<std::vector<long long>> dist(H, std::vector<long long>(W, LINF));
  dist[sy][sx] = 0;

  typedef std::pair<long long, std::pair<int, int>> PLPII;
  std::priority_queue<PLPII, std::vector<PLPII>, std::greater<PLPII>> que;
  que.push(std::make_pair(0LL, std::make_pair(sx, sy)));

  while (!que.empty()) {
    PLPII now = que.top();
    que.pop();
    long long cur_d = now.first;
    int cur_x = (now.second).first;
    int cur_y = (now.second).second;

    if (dist[cur_y][cur_x] < cur_d) {
      continue;
    }
    for (int i = 0; i < 4; i++) {
      int nx = cur_x + dx[i];
      int ny = cur_y + dy[i];
      if (nx < 0 || W <= nx || ny < 0 || H <= ny) {
        continue;
      }
      if (maze[ny][nx] == '#') {
        continue;
      }
      long long cost = 0;

      if (dist[cur_y][cur_x] + cost < dist[ny][nx]) {
        dist[ny][nx] = dist[cur_y][cur_x] + cost;
        que.push(std::make_pair(dist[ny][nx], std::make_pair(nx, ny)));
      }
    }
    for (int ny = cur_y - 2; ny <= cur_y + 2; ny++) {
      for (int nx = cur_x - 2; nx <= cur_x + 2; nx++) {
        if (nx < 0 || W <= nx || ny < 0 || H <= ny) {
          continue;
        }
        if (maze[ny][nx] == '#') {
          continue;
        }
        long long cost = 1;

        if (dist[cur_y][cur_x] + cost < dist[ny][nx]) {
          dist[ny][nx] = dist[cur_y][cur_x] + cost;
          que.push(std::make_pair(dist[ny][nx], std::make_pair(nx, ny)));
        }
      }
    }
  }
  return dist;
}

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

  int H, W;
  cin >> H >> W;

  int sh, sw;
  cin >> sh >> sw;
  sh--;
  sw--;

  int gh, gw;
  cin >> gh >> gw;
  gh--;
  gw--;

  maze.assign(H, vector<char>(W));

  for (int y = 0; y < H; y++) {
    string s;
    cin >> s;
    for (int x = 0; x < s.length(); x++) {
      maze[y][x] = s[x];
    }
  }

  auto dist = dijkstra(sw, sh, maze);
  cout << (dist[gh][gw] == LINF ? -1 : dist[gh][gw]) << "\n";

  return 0;
}


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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());


signed main()
{
    gearup;
    string a,b,c; cin >> a >> b >> c;
    int A = a.size();
    int B = b.size();
    int C = c.size();
    if(a[A-1] == b[0] && b[B-1] == c[0])out("YES");
    else out("NO");
}

Measured memory_bytes: 3644
import sys
import heapq


input = sys.stdin.readline
n, m = map(int, input().split())
a_list = list(map(int, input().split()))
a_list = list(map(lambda x: x*(-1), a_list))
heapq.heapify(a_list)

while m > 0:
    max_a = heapq.heappop(a_list)
    heapq.heappush(a_list, (-1)*(-max_a//2))
    m -= 1

print(-sum(a_list))


Measured memory_bytes: 20024
/**
 *    author:  zjsdut
 *    created: 2020/03/10 11:40:20
 **/
#include <bits/stdc++.h>

using namespace std;

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

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

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

template <typename T> istream &operator>>(istream &stream, vector<T> &vec) {
  for (auto &x : vec)
    stream >> x;
  return stream;
}

void scan() {}

template <class T, class... Args> void scan(T &a, Args &... rest) {
  cin >> a;
  scan(rest...);
}

using ll = long long;
using vl = vector<ll>;
using vb = vector<bool>;
using vi = vector<int>;
using pii = pair<int, int>;
template <typename T> using vv = vector<vector<T>>;
#define rng(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define up(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define down(i, b, a) for (int i = int(b); i >= int(a); i--)
#define rep(n)                                                                 \
  for (int _iter_##n = 0, _num_##n = (int)n; _iter_##n < _num_##n; ++_iter_##n)
#define FOR(x, cont) for (const auto &x : cont)
#define For(x, cont) for (auto &x : cont)
#define all(x) begin(x), end(x)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ep emplace
#define SZ(x) (int)(x).size()
#define UNIQ(vec) (vec).erase(unique(all(vec)), end(vec))
#define LB(cont, x) int(lower_bound(all(cont), x) - begin(cont))
#define UB(cont, x) int(upper_bound(all(cont), x) - begin(cont))

template <typename T>
ostream &operator<<(ostream &stream, const vector<T> &vec) {
  if (!vec.empty()) {
    stream << vec[0];
    for (size_t i = 1; i != vec.size(); ++i)
      stream << ' ' << vec[i];
  }
  return stream;
}

template <typename T> void print(const vector<T> &t) { cout << t << '\n'; }

template <typename T> void print(const vector<vector<T>> &t) {
  for (const auto &row : t) {
    print(row);
  }
}

template <typename T> void print(const T &t) { cout << t << ' '; }

template <typename T, typename... Args>
void print(const T &t, const Args &... rest) {
  print(t);
  print(rest...);
}

template <typename T> void println(const T &t) { cout << t << '\n'; }

template <typename T, typename... Args>
void println(const T &t, const Args &... rest) {
  print(t);
  println(rest...);
}

int main() {
#if defined LOCAL
  ifstream in("in.txt");
  cin.rdbuf(in.rdbuf());
#endif
  int n;
  scan(n);
  vi a(n);
  scan(a);
  sort(all(a));
  rng (i, 1, n) {
    if (a[i] == a[i - 1]) {
      println("NO");
      return 0;
    }
  }
  println("YES");
  return 0;
}

Measured memory_bytes: 1024