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

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int> > vp;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define out(n) cout << (n) << endl;

// __attribute__((constructor))
// void initial() {
//   cin.tie(0);
//   ios::sync_with_stdio(false);
// }

int main() {
  int n, m, d[100001] = {0};
  cin >> n >> m;

  int a, b;
  rep(i, 0, m) {
    cin >> a >> b;
    d[a]++, d[b]++;
  }

  rep(i, 0, n + 1) {
    if(d[i] & 1) {
      printf("%s", "NO");
      return 0;
    }
  }

  printf("%s", "YES");
}


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

using namespace std;

#define FOR(i,a,b)  for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n)    FOR(i,0,n)
#define ALL(a)      a.begin(),a.end()
#define vi          vector<int>
#define vvi         vector<vi>
#define P           pair<int,int>
#define vP          vector<P>
#define vvP         vector<vP>

int Digit(int num){
    int sum=0,dig=0;
    while(num){
        dig=num%10;
        sum+=dig;
        num/=10;
    }
    return sum;
}

int main(){
    int n,a,b;cin>>n>>a>>b;
    int res=0;
    FOR(i,1,n+1){
        int t=Digit(i);
        if(a<=t and t<=b){
            res+=i;
        }
    }
    cout<<res<<"\n";
    return 0;
}


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

#define flin            freopen("input.txt", "r", stdin); 
#define flout           freopen("output.txt", "w", stdout);
#define ll              long long
#define ull             unsigned long long
#define fastio          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl              '\n'
#define nll             '\0'
#define pb              push_back
#define bdyptb          return 0;
#define sorted(x)       sort(x.begin(), x.end())
#define reversed(x)     reverse(x.begin(), x.end())
#define all(x)          x.begin(), x.end()
#define mset(a, b)      memset(a, b, sizeof(a));
#define testcase        ll t,tt; cin>>tt; for(t=1;t<=tt;t++)

#define pi acos(-1.00)   
#define mx 1000007

using namespace std;

int main()
{
	fastio;
	int x;
	cin>>x;
	if(x<30)
		cout<<"No";
	else cout<<"Yes";
	 

    
}

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

int main() {
  int n , p, a=0, b=0; cin >> n >> p;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    if (arr[i]%2==0)
      a++;
    else
      b++;
  }
  long long x = pow(2, a+b-1);
  if (p%2==0 && b==0)
    cout << x*2 << endl;
  else if (p%2!=0 && b==0)
    cout << 0 << endl;
  else
    cout << x << endl;
  return 0;
}
  


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

int main() {
    int n;
    scanf("%d", &n);
    int *p = malloc((n + 1) * sizeof(int));
    for (int i = 1; i <= n; i++) {
        scanf("%d", &p[i]);
    }
    int ans = 0;
    for (int i = 2; i <= n - 1; i++) {
        int dif_1 = p[i] - p[i-1];
        int dif_2 = p[i] - p[i+1];
        if ((dif_1 < 0 && dif_2 > 0) || (dif_1 > 0 && dif_2 < 0))
            ans++;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.Set;
public class Main {
	public static void main(String[] args){
		Main main = new Main();
		main.solveA();
	}

	private void solveA() {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if (a - b == b - c) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 23508
x, k, d = map(int, input().split())
x = abs(x)

y = x // d


if k >= y:
    if (k - y) % 2 == 0:
        print(abs(x - y*d))
    else:
        print(abs(x - (y+1) * d))

else:
    print(abs(x - k * d))


Measured memory_bytes: 9052
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int N,K;
  cin>>N>>K;
  VEC<int>H(N);
  REP(i,0,N)cin>>H[i];
  int cnt=0;
  REP(i,0,N){
    if(H[i]>=K)cnt++;

  }
  cout<<cnt<<endl;


  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <string>
#include <map>

using namespace std;

int main(){
  int i,j,k,l,m,n,t;
  string s;
  cin >> n >> t;
  int c[n],ti[n];
  for(i=0;i<n;i++){
    cin >> c[i] >> ti[i];
  }
  int mi=2000;
  for(i=0;i<n;i++){
    if(ti[i]<=t)mi=min(mi,c[i]);
  }
  if(mi!=2000)cout << mi << endl;
  else cout << "TLE" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>

using namespace std;

struct Point {
	double x, y;
	Point() : x(0), y(0) { }
	Point(double x, double y) : x(x), y(y) { }
	Point operator+(const Point &p) const { return Point(x + p.x, y + p.y); }
	Point operator-(const Point &p) const { return Point(x - p.x, y - p.y); }
	Point operator*(double s) const { return Point(x * s, y * s); }
	Point operator/(double s) const { return Point(x / s, y / s); }
	Point &operator+=(const Point &p){ x += p.x; y += p.y; return *this; }
	Point &operator-=(const Point &p){ x -= p.x; y -= p.y; return *this; }
	Point &operator*=(double s){ x *= s; y *= s; return *this; }
	Point &operator/=(double s){ x /= s; y /= s; return *this; }
	bool operator==(const Point &p) const { return x == p.x && y == p.y; }
	bool operator!=(const Point &p) const { return x != p.x || y != p.y; }
	bool operator<(const Point &p) const {
		return (x == p.x) ? (y < p.y) : (x < p.x);
	}
};
inline Point operator*(double s, const Point &p){ return p * s; }

inline double norm(const Point &p){ return p.x * p.x + p.y * p.y; }
inline double abs(const Point &p){ return sqrt(norm(p)); }
inline double arg(const Point &p){ return atan2(p.y, p.x); }
inline Point unit(const Point &p){ return p / abs(p); }
inline Point ortho(const Point &p){ return Point(-p.y, p.x); }
inline double cross(const Point &a, const Point &b){
	return a.x * b.y - a.y * b.x;
}
inline double dot(const Point &a, const Point &b){
	return a.x * b.x + a.y * b.y;
}

class Polygon {
private:
	vector<Point> m_points;
public:
	Polygon() : m_points() { }
	template <typename Iterator>
	Polygon(Iterator begin, Iterator end) : m_points(begin, end) { }
	const Point &operator[](int i) const {
		return m_points[i % m_points.size()];
	}
	Point &operator[](int i){ return m_points[i % m_points.size()]; }
	size_t size() const { return m_points.size(); }
};

inline double area(const Polygon &g){
	const int n = g.size();
	double sum = 0;
	for(int i = 0; i < n; ++i){ sum += cross(g[i], g[i + 1]); }
	return sum * 0.5;
}
inline int contains(const Polygon &g, const Point &p){
	const int n = g.size();
	int result = 0;
	for(int i = 0; i < n; ++i){
		Point a = g[i] - p, b = g[i + 1] - p;
		if(a.y > b.y){ swap(a, b); }
		if(a.y <= 0 && 0 < b.y && cross(a, b) < 0){ result = 1 - result; }
		if(cross(a, b) == 0 && dot(a, b) <= 0){ return -1; } // on line
	}
	return result;
}

int main(){
	ios_base::sync_with_stdio(false);
	cout << setiosflags(ios::fixed) << setprecision(1);
	int n;
	cin >> n;
	vector<Point> points(n);
	for(int i = 0; i < n; ++i){ cin >> points[i].x >> points[i].y; }
	cout << abs(area(Polygon(points.begin(), points.end()))) << endl;
	return 0;
}

Measured memory_bytes: 1304
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

#define MAX 4000000

signed main() {
    int n;
    cin >> n;
    int sum = 0;
    int a[n];
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
    }
    bitset<MAX + 1> dp;
    dp[0] = true;
    for (int i = 0; i < n; i++) {
        dp |= dp << a[i];
    }
    for (int i = (sum + 1) / 2; i <= sum; i++) {
        if (dp[i]) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<queue>
#include<stack>

using namespace std;

#define INF 999999999
#define REP(i,n) for(int i=0; i<(int)(n); i++)

vector<string> in(72);
string dp[72][72];
string ans;

bool com(string a, string b){
	if(a.size() > b.size()) return true;
	else if(a.size() == b.size()){
		REP(i, a.size()){
			if(a[i] > b[i]) return true;
			else if(a[i] < b[i]) return false;
		}
		return true;
	}
	else return false;
}

int main(){
	int i, j, w, h;
	string p;
	while(1){
		cin >> w >> h;
		if(!w) break;
		REP(a,h){
			cin >> in[a+1];
			in[a+1].insert(in[a+1].begin(),'A');
			in[a+1].insert(in[a+1].end(),'A');
		}
		in[h+1] = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
		in[0] = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
		REP(a,h+2) dp[a][0]="";
		REP(a,w+2) dp[0][a]="";
		dp[1][1] = "";
		ans ="";
		for(i=1;i<=h;i++){
			for(j=1;j<=w;j++){
				if(in[i][j]-'0'>=0&&in[i][j]-'0'<=9){
					dp[i][j] = "";
					if(dp[i-1][j]!=""){
						dp[i][j] = dp[i-1][j];
					}
					if(dp[i][j-1]!=""){
						if(com(dp[i][j-1],dp[i][j])) dp[i][j] = dp[i][j-1];
					}
					if(!(dp[i][j]==""&&in[i][j]=='0'))dp[i][j].insert(dp[i][j].end(), in[i][j]);
				}
				else dp[i][j] ="";
			}
		}
		ans = "";
		for(i=1;i<=h;i++){
			for(j=1;j<=w;j++){
				if(com(dp[i][j],ans)) ans = dp[i][j];
			}
		}
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1432
#include <iostream>
#include <queue>
#include <tuple>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
using namespace std;
int main() {
    int k, t; cin >> k >> t;
    priority_queue<pair<int,int> > que;
    repeat (i, t) {
        int a; cin >> a;
        que.emplace(a, i);
    }
    int ans = 0;
    int last = -1;
    while (not que.empty()) {
        int a, i; tie(a, i) = que.top(); que.pop();
        if (i != last) {
            last = i;
            a -= 1;
            if (a) que.emplace(a, i);
        } else {
            if (que.empty()) { ans += a; break; }
            int b, j; tie(b, j) = que.top(); que.pop();
            last = j;
            b -= 1;
            que.emplace(a, i);
            if (b) que.emplace(b, j);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
    long long n,a,b;

    scanf("%lld %lld %lld",&n,&a,&b);

    if((b-a)%2==0)
    {
        printf("%lld",(b-a)/2);
    }
    else
    {
        if(a-1<n-b)
        {
            printf("%lld",a+(b-a-1)/2);
        }
        else
        {
            printf("%lld",n-b+1+(b-a-1)/2);
        }
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define eps 1e-7
#define all(x) ((x).begin()),((x).end())
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define int ll
const bool debug = 0;
using pii = pair<int, int>;
typedef long double D;
 
int32_t main()
{
    usecppio
    int n, m; cin >> n >> m;
    if (n%2==1)
    {
        for (int i = 1; i<=m; i++)
            cout << i << ' ' << n-i << '\n';
    }
    else
    {
        int odd = (m+1)/2;
        for (int i = 1; i<=odd; i++)
            cout << i << ' ' << n-i+1 << '\n';
        for (int i = odd+1; i<=m; i++)
            cout << i << ' ' << n-i << '\n';
    }
}


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

static const int INFTY=1001;
static const int MAX = 10;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int H, W;
int c[10][10];
int d[MAX];
int color[MAX];

void dijkstra(){
    int minv;
    for (int i=0; i<MAX; i++){
        d[i] = INFTY;
        color[i] = WHITE;
    }

    d[1] = 0;
    color[0] = GRAY;
    while(true){
        minv = INFTY;
        int u = -1;
        for(int i=0; i<MAX; i++){
            if(minv>d[i] && color[i]!=BLACK){
                u = i;
                minv = d[i];
            }
        }
        if(u==-1) break;
        color[u] = BLACK;
        for(int v=0; v < MAX; v++){
            if(color[v]!=BLACK && c[u][v]!=INFTY){
                if(d[v]>d[u] + c[u][v]){
                    d[v] = d[u] + c[u][v];
                    color[v] = GRAY;
                }
            }
        }
    }
}
int main(){
    cin >> H;
    cin >> W;
    int A[H][W];
    for(int i=0; i<=9; i++){
        for(int j=0; j<=9; j++){
            cin >> c[j][i];
        }
    }
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> A[i][j];
        }
    }
    dijkstra();

    int ans_cost = 0;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(A[i][j]>-1){
                ans_cost = ans_cost + d[A[i][j]];
            }
        }
    }
    cout << ans_cost << '\n';
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=998244353;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

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

int n;
vl a;

int main(){
	cin>>n;
	a=vl(n);
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a.begin(),a.end());
	ll t=a[0];
	for(int i=1;i<n;i++) (t*=gcd(a[i],i)%mod)%=mod;
	cout<<t<<endl;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> l(n), r(n);
    for(int i=0;i<n;i++)cin >> l[i] >> r[i];
    int ans = 0;
    for(int i=0;i<n;i++) ans += r[i]-l[i]+1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int n, a, b;
	cin >> n >> a >> b;
	int pass = 0, pass_f = 0;
	string s;
	cin >> s;
	for(int i = 0; i < s.length(); i++){
		if(s.at(i) == 'c'){
			cout << "No" << endl;
		}else if(s.at(i) == 'a'){
			if(pass < a + b){
				cout << "Yes" << endl;
				pass++;
			}else{
				cout << "No" << endl;
			}
		}else{
			if(pass < a + b && pass_f < b){
				cout << "Yes" << endl;
				pass++;
				pass_f++;
			}else{
				cout << "No" << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <deque>

using namespace std;
int n;
long long k;
const int MAX_N = 2e5 + 5;
const int D = 60;
int to[D][MAX_N];

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> to[0][i];
        to[0][i]--;
    }

    for (int i = 0; i < D - 1; ++i) {
        for (int j = 0; j < n; ++j) {
            to[i + 1][j] = to[i][to[i][j]];
        }
    }

    int v = 0;
    for (int i = D - 1; i >= 0; --i) {
        long long l = (long long) 1 << i; // l = 2^i
        if (l <= k) {
            v = to[i][v];
            k -= l;
        }
    }
    cout << v + 1 << endl;
    return 0;
}

Measured memory_bytes: 50496
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define mp  make_pair

ll ceil(ll a,ll b){
	if(a%b==0)
		return a/b;
	else
		return a/b+1;
}

int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ll n,k;
	cin>>n>>k;
	ll arr[n];
	for(int i=0;i<n;++i)
		cin>>arr[i];
	cout<<ceil(n-1,k-1)<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

const int LEFT = -1;
const int RIGHT = 1;

int check(char c) {
	string left = "qazwsxedcrfvtgb";
	if(left.find(c) != string::npos) {
		return LEFT;
	} else {
		return RIGHT;
	}
}

int main() {
	string str;	
	while(cin >> str) {
		if(str == "#") break;
		int ans = 0;
		REP(i, 1, str.size()) {
			if(check(str[i-1]) != check(str[i])) {
				ans++;	
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int ans = min(A*N, B);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int
main(void)
{
	char line[80];
	int n;
	long s = 100000;
	
	if (fgets(line, sizeof line, stdin)) {
		if (sscanf(line, "%d", &n) == 1) {
			for (int i = 0; i < n; i++) {
				s = s * 1.05;
				s = ceil(s / 1000.0) * 1000;
			}

			printf("%ld\n", s);
		}
	}

	return 0;
}

Measured memory_bytes: 1036
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string x,y;
	cin>>x;
	int a=x.size();
	if((x[a-1]-'a')!=('s'-'a'))
	{
		cout<<x<<"s";
	}
	else
	{
		cout<<x<<"es";
	}
	return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>

int main(void)
{
  int n;
  scanf("%d",&n);
  int nn,nlength,ans=0,i;
  for(i=1;i<=n;i++){
    nn = i;
    nlength = 0;
    while(nn!=0){
    nn /= 10;
    nlength++;
    }
    if(nlength%2==1)
      ans++;
  }
  printf("%d\n",ans);
  return 0;
}

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

int main(void) {

	int n;
	int m;
	int A[100][100] = { {} };
	int i;
	int j;
	int B[100] = {};

	cin >> n >> m;

	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)
		{
			cin >> A[i][j];

		}

	}

	for (j = 0; j < m; j++)
	{
		cin >> B[j];
	}

	
	for (i = 0; i < n; i++)
	{
		int x = 0;

		for (j = 0; j < m; j++)
		{
			x += A[i][j] * B[j];
			
		}

		cout << x << endl;
	}
	return 0;
}


Measured memory_bytes: 3128
#!/usr/bin/env python
from collections import defaultdict
import math
import re

def main():
    #H, W = map(int, input().split())
    N = int(input().strip())
    D = list(map(int, input().split()))

    D = sorted(D)

    middle = N // 2
    lower = D[middle-1]
    higher = D[middle]

    num = higher - lower
    print(num)



if __name__ == '__main__':
    main()


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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/


  int a;

  int ans=0;
  
  for(int i=0;i<10;i++){

    cin>>a;

    ans+=a;
  }

  cout<<ans<<endl;
  
  return 0;

}



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

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

using namespace std;

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


Measured memory_bytes: 3636
#include<stdio.h>
int arr[15];

int main(){
    for(int i=0; i<3; i++){
        int x;
        scanf("%d",&x);
        arr[x-1]++;
    }

    if(arr[4]==2 && arr[6]==1){
        printf("YES");
    }
    else{
        printf("NO");
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int n, f[110][11], p[110][11], ans = -(1 << 30), cnt, c;
int main(){
	cin >> n;
	rep(i, n) {
		rep(j, 10) {
			cin >> f[i][j];
		}
	}
	rep(i, n) {
		rep(j, 11) {
			cin >> p[i][j];
		}
	}
	for (int i = 1;i < (1 << 10);i++) {
		cnt = 0;
		rep(j, n) {
			c = 0;
			rep(k, 10)if ((i >> k & 1) && f[j][k]) c++;
			cnt += p[j][c];
		}
		ans = max(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 200010 };
const ll MOD { 998244353 }, oo { 1LL << 62 };

ll fs[MAX];

ll st[MAX][2];

void precomp()
{
    fs[0] = fs[1] = 1;

    for (ll i = 2; i < MAX; ++i)
        fs[i] = (fs[i - 1] * i) % MOD;
}

ll mod_pow(ll a, ll n)
{
    ll res = 1, base = a;

    while (n)
    {
        if (n & 1)
            res = (res * base) % MOD;

        base = (base * base) % MOD;
        n >>= 1;
    }

    return res;
}

ll inv(ll N)
{
    return mod_pow(N, MOD - 2);
}

ll C(ll N, ll M)
{
    auto res = (fs[N] * inv(fs[N - M])) % MOD;
    res = (res * inv(fs[M]) % MOD);

    return res;
}


ll solve(ll N, ll M, ll K)
{
    auto ans = mod_pow(M - 1, N - 1);
    ans = (ans * M) % MOD;

#ifdef DEBUG
    cout << "--- ans = " << ans << endl;
#endif
    for (ll i = 1; i <= K; ++i)
    {
        ll res = (C(N - 1, i) * mod_pow(M - 1, N - 1 - i)) % MOD;
        res = (M * res) % MOD;
        ans = (ans + res) % MOD;
    }

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);
    precomp();

    ll N, M, K;
    cin >> N >> M >> K;

    auto ans = solve(N, M, K);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 5240
S=input()
l=len(S)
Y=0
M=0
for i in range(l):
    if i==3:
        if int(S[i-1])==0 and 1<=int(S[i])<=9:
            Y=1
        elif int(S[i-1])==1 and 0<=int(S[i])<=2:
            Y=1
for i in range(l):
    if i==1:
        if int(S[i-1])==0 and 1<=int(S[i])<=9:
            M=1
        elif int(S[i-1])==1 and 0<=int(S[i])<=2:
            M=1
if Y==1 and M==1:
    print('AMBIGUOUS')
elif Y==1 and M==0:
    print('YYMM')
elif Y==0 and M==1:
    print('MMYY')
elif Y==0 and M==0:
    print('NA')

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

#define rep(i, n) for(int i = 0; i < n; i++)
#define loop(i, s, n) for(int i = s; i < n; i++)
#define MOD 1e9+7
void max_self(int &a, int b) { a=a>b?a:b; }
void min_self(int &a, int b) { a=a<b?a:b; }

using namespace std;

int h, a;

int main() {
    cin >> h >> a;

    int temp = (h+a-1)/a;

    cout << temp << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i< (int) n; i++)
 
 
int main() {
    int  N;
    cin >> N;


    vector <int>V(N);
    vector <int>C(N);

    rep(i,N) cin >> V[i];
    rep(i,N) cin >> C[i];


    vector <int> kati(N);
    rep(i,N) kati[i] = V[i]-C[i];

    int ans =0;
    rep(i,N){
        if(  kati[i] > 0){
            ans += kati[i];
        }
    }
    cout << ans << endl;


    }


    


Measured memory_bytes: 256
# 入力
s = input()
n = len(s)

l = (n - 1) // 2
r = (n + 3) // 2

if s == s[::-1] and s[0:l] == s[0:l][::-1] and s[r-1:n] == s[r-1:n][::-1]:
    print('Yes')
else:
    print('No')

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

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long 

// fact(n)
int fact(int n){
	if(n == 1)	return 1;
	else return (n * fact(n - 1));
}

// combination(n,r)
int combination(int n, int r){
	if(r == 0 || r == n)	return 1;
	else if(r == 1)	return n;
	return (combination(n - 1, r - 1) + combination(n - 1, r));
}

// gcd(a,b)
int gcd(int a,int b){
	int ret;
	ret = (b == 0) ? a : gcd(b, a % b);
	return ret;
}

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

// qsort(array, size, sizeof(int),comp);
int comp(const int *a,const int *b){
	return (*a - *b);
}

// append(array,*size,addNum)
void append(int *array,int *size,int num){
	realloc(array, sizeof(int) * (*size + 1));
	array[(*size)] = num;
	++(*size);
}

// pop(array,*size) & nongetpop(array,*size)
int pop(int *array,int *size){
	int temp = array[(*size - 1)];
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
	return temp;
}

void nongetpop(int *array,int *size){
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
}

int main(int argc, char const *argv[])
{
	int a,b,x;
	scanf("%d%d%d",&a,&b,&x);
	if(a <= x && x <= a + b)	puts("YES");
	else puts("NO");
	return 0;
}



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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 100001

int N,M;

vi adj[maxn];
bool vis[maxn];
int ans[maxn];
int dist[maxn];

int main(){
	fast;
	
	cin>>N>>M;
	
	FOR(i,1,M){
		int a,b;
		cin>>a>>b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	
	queue <pi> q;
	q.push(pi(1,0));
	while (!q.empty()){
		pi cur = q.front(); q.pop();
		
		if (vis[cur.f]) continue;
		vis[cur.f] = 1;
		dist[cur.f] = cur.s;
		aFOR(i,adj[cur.f]){
			q.push(pi(i,cur.s+1));
		}
	}
	FOR(i,2,N){
		aFOR(j,adj[i]){
			if (dist[j] + 1 == dist[i]) ans[i] = j;
		}
	}
	cout<<"Yes\n";
	FOR(i,2,N) cout<<ans[i]<<'\n';
	
}



Measured memory_bytes: 17080
N = int(input())
S = input()
A = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
ans = []
for i in range(len(S)):
    B = A.index(S[i])
    ans.append(A[B+N])
print(''.join(ans))

Measured memory_bytes: 3188
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
const (
	P = 1000000007
)

func calc(x []int) int {
	res := 0
	n := len(x) - 1
	for i := 1; i <= n; i++ {
		l := x[i] - x[i-1]
		res = (res + l*i*(n-(i-1))) % P
	}
	return res
}

func main() {
	defer stdout.Flush()

	n := readInt()
	m := readInt()
	x := make([]int, n)
	y := make([]int, m)
	for i := range x {
		x[i] = readInt()
	}
	for i := range y {
		y[i] = readInt()
	}

	println(calc(x) * calc(y) % P)
}


Measured memory_bytes: 4736
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n,x,sum=0;
  cin >> n >> x;
  vector<int>m(n);
  for(int i=0; i<n; i++){
    cin >> m.at(i);
    sum+=m.at(i);
  }
  sort(m.begin(),m.end());
  x=x-sum;
  n+=x/m.at(0);
  cout << n << endl;
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

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


void Main() {
	int K, A, B; cin >> K >> A >> B;
	for (int i = A; i <= B; i++) {
		if (i % K == 0) {
			cout << "OK" << endl;
			return;
		}
	}
	cout << "NG" << endl;
}

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


Measured memory_bytes: 3640
from collections import defaultdict
from itertools import product, groupby
from math import pi
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = 10 ** 20


def main():
    N = int(input())
    a_list = list(map(int, input().split()))
    total = sum(a_list)

    dp1 = [0] * N
    dp1[0] = a_list[0]
    for i in range(1, N):
        dp1[i] = a_list[i] + dp1[i - 1]

    ans = INF
    for i in range(N - 1):
        ans = min(ans, abs(dp1[i] - (total - dp1[i])))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 25320
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to;
	ld cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	/*if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;*/
	return ((a.x + 1)*(a.y + 1)) < ((b.x + 1)*(b.y + 1));
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
int ctoi(char a) {
	return (int)a - '0';
}
 //#define int long long
const long long Inf = 4523372036854775807;
const int inf = 1500000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int n;
	cin >> n;
	if (n == 3) {
		cout << "2 5 63\n";
		return 0;
	}
	vector<int>v2, v3, v6;
	for (int i = 1; i <= 30000; i++) {
		if (i % 2 == 0 && i % 3 == 0) v6.push_back(i);
		else if (i % 2 == 0) v2.push_back(i);
		else if (i % 3 == 0) v3.push_back(i);
	}
	set<int>ans;
	for (int i = 0; i < v2.size() && n >= 4; i += 2) {
		ans.insert(v2[i]);
		ans.insert(v2[i + 1]);
		n -= 2;
	}
	for (int i = 0; i < v3.size() && n >= 2; i+=2) {
		ans.insert(v3[i]);
		ans.insert(v3[i + 1]);
		n -= 2;
	}
	int sum = 0;
	while (n > 0) {
		ans.insert(v6[sum]);
		sum++; n--;
	}
	set<int>::iterator it = ans.begin();
	sum = 0;
	while (it != ans.end()) {
		if (!sum) {
			cout << (*it);
			sum++;
		}
		else cout << " " << (*it);
		it++;
	}
	cout << endl;
	getchar(); getchar();
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<iomanip>

using namespace std;
int main(void) {
	char S[10];
	int a = 0;
	int max = 0;
	int i;

	cin >> S;


	for (i = 0; i < 10; i++) {
	
		if ((S[i] == 'A') || (S[i] == 'C') || (S[i] == 'G') || (S[i] == 'T')) {
			a++;
			if (a > max)
				max = a;
		}
			
		
		else 
			a=0;


	}
	cout << max;
	return 0;


}

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

#include <cstdio>

using namespace std;

int main(){
    int n, a; cin >> n >> a;
    vector<vector<long long>> acc(n, vector<long long>(a*n+1));
    for(int i=0; i<n; ++i){
        int x; cin >> x;
        if(x>a*n) continue;
        for(int j=i-1; j>=0; --j){
            for(int k=0; k<=a*n; ++k){
                if(k+x<=a*n){
                    acc[j+1][k+x]+=acc[j][k];
                }
            }
        }
        ++acc[0][x];
    }
    long long ans=0;
    for(int i=0; i<n; ++i){
        ans+=acc[i][(i+1)*a];
    }

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


Measured memory_bytes: 1280
import java.io.*
import java.util.*

fun solve(s: Int){
    fun collatz(x: Int) = if (x%2==0) x/2 else 3*x+1
    var ret = mutableMapOf(s to 1)
    var next = s
    var count = 2
    while(true){
        next = collatz(next)
        ret[next]?.let{ println(count); return }
        ret[next] = 1
        count++
    }
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val s = sc.next().toInt()
    solve(s)
}



Measured memory_bytes: 31520
#include<iostream>
#include<algorithm>
#include<vector>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define MAX 2000000
using namespace std;
int par[MAX];
int N,Q;

void init()
{
  rep(i,MAX)par[i] = i;
}

int find(int x)
{
  if(x == par[x])return x;
  return find(par[x]);
}

bool unit(int x,int y)
{
  x = find(x);
  y = find(y);
  if(x != y)par[y] = x;
}

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

int main()
{
  while(cin >> N >> Q,N|Q)
    {
      init();
      REP(i,1,N)
	{
	  int variable;
	  cin >> variable;
	  variable--;
	  par[i] = variable;
	}

      long long cost = 0;
      rep(i,Q)
	{
	  char Query;
	  int v;
	  cin >> Query >> v;
	  v--;
	  if(Query == 'Q')
	    {
	      cost += find(v)+1;
	    }
	  else 
	    {
	      par[v] = v;
	    }
	}
      cout << cost << endl;
    }
  return 0;
}

 

Measured memory_bytes: 8968
#include <stdio.h>
int main(void){
   int a,b;
   char op;
   scanf("%d %c %d",&a,&op,&b);
   while(1){
       if(op == '+'){
           printf("%d\n",a+b);
       }else if(op == '-'){
           printf("%d\n",a-b);
       }else if(op == '*'){
           printf("%d\n",a*b);
       }else if(op == '/'){
           printf("%d\n",a/b);
       }else{
           return 0;
       }
       scanf("%d %c %d",&a,&op,&b);
       
   }
}

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

int main(void) {
    int N, K;
    cin >> N >> K;
    vector<long long> v;
    for (int i = 0; i < N; i++) {
        long long val;
        cin >> val;
        v.push_back(val);
    }
    long long ans = 0;
    for (int l = 0; l <= min(N, K); l++) {
        for (int r = 0; r + l <= min(N, K); r++) {
            priority_queue<long long, vector<long long>, greater<long long>> pq;
            for (int i = 0; i < l; i++) {
                pq.push(v[i]);
            }
            for (int i = 0; i < r; i++) {
                pq.push(v[v.size() - 1 - i]);
            }
            int pop_cnt = min((r + l), K - (r + l));
            for (int i = 0; i < pop_cnt; i++) {
                long long top = pq.top();
                if (top >= 0) break;
                pq.pop();
            }

            long long sum = 0;
            while (!pq.empty()) {
                sum += pq.top();
                pq.pop();
            }
            ans = max(ans, sum);
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main()
{
    char a,b;
    cin >> a>>b;
    if((a=='H')&&(b=='H')){
    cout<< "H";
    }else if ((a=='H')&&(b=='D')){
    cout<<"D";
    }if ((a=='D')&&(b=='H')){
    cout<<"D";

    }else if((a=='D')&&(b=='D')){

    cout<<"H";
    }

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
bool is_prime(long long n) {  //素数判定
  for(int64_t i = 2; i * i <= n; i++) {
    if(n % i == 0) return false;
  }
  return true;
}
int solve(){
  ll h,n;
  cin >> h >> n;
  cout << (h + n - 1) / n << endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16) << endl; 
  solve();
  return 0;
} 

Measured memory_bytes: 256
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li      int32_t
#define lli     long long
#define ulli unsigned long long

#define pn          printf("\n")
#define nl          cout<<'\n'
#define sf(N)       scanf("%lld",&N)
#define pf(N)       printf("%lld",N)
#define sl          cout<<' '
#define ps          printf(" ")

#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))

#define pb      push_back
#define pob     pop_back
#define itr     iterator
#define sz()    size()
#define szof    sizeof
#define lb      lower_bound
#define ub      upper_bound
#define mp      make_pair
#define vlli    vector<lli>
#define plli    pair<lli,lli>
#define vplli   vector<plli >
#define F       first
#define S       second
#define ALL(V)  V.begin(),V.end()
#define Dup erase(unique(V.begin(),V.end()),V.end())

#define Inf     1000000000000000
#define mod     1000000007
using namespace std;

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

lli Count[10];

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/
    
    memset(Count,1,szof(Count));
    
    lli N,i,K;
    cin>>N>>K;
    
    vlli V(K);
    rep(i,0,K)
    {
        cin>>V[i];
    
        Count[V[i]]=0;
    }
    
    rep(i,N,10000001+N)
    {
        I flag=1;
        lli j=i;
        
        while(j)
        {
            if(!Count[j%10])
            {
                flag=0;
                break;
            }
            j/=10;
        }
        
        if(flag)
        {
            cout<<i;
            exit(0);
        }
    }
    
    
    
    
    
    
    
    
    


 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set1;
typedef tree<string,null_type,less<string>,rb_tree_tag,tree_order_statistics_node_update> indexed_set2;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

int main() 
{
    ll n,k,c;
    cin>>n>>k>>c;
    string s;
    cin>>s;

    ll arr1[k+1] = {0},arr2[k+1] = {0};
    ll d = 1;
    ll diff = c;
    REP(i,0,n){
        if(s[i] == 'o'){
            if(diff >= c && d<=k){
                arr1[d] = i;
                d++;
                diff = 0;
            }
            else {
                diff++;
            }
        }
        else {
            diff++;
        }
    }
    d = k;
    diff = c;

    REPI(i,0,n){
        if(s[i] == 'o'){
            if(diff >= c && d > 0){
                arr2[d] = i;
                d--;
                diff = 0;
            }
            else {
                diff++;
            }
        }
        else {
            diff++;
        }
    } 
    REP(i,1,k+1){
        if(arr1[i] == arr2[i]){
            cout<<arr1[i]+1<<endl;
        }
    }
	return 0;
}

Measured memory_bytes: 6836
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cctype>
using namespace std;
const int maxM=5010;
const int maxn=1010;
const int INF=0x3f3f3f3f;
int f[maxn],g[2][maxM],n;
int head[maxn],tot,v[maxn];
struct edge {
    int v,next;
} e[maxn];
void addEdge(int u,int v) {
    e[++tot].v=v;
    e[tot].next=head[u];
    head[u]=tot;
}
void cl(int t) {
    memset(g[t],0x3f,sizeof(g[t]));
}
void dfs(int x) {
    for(int i=head[x]; i; i=e[i].next)
        dfs(e[i].v);
    cl(0);
    int X=0;
    g[X][0]=0;
    for(int i=head[x]; i; i=e[i].next) {
        int y=e[i].v;
        X=-X+1;
        cl(X);
        for(int j=0; j<v[x]+1; j++) {
            if(j-f[y]>=0)
                g[X][j]=min(g[1-X][j-f[y]]+v[y],g[X][j]);
            if(j-v[y]>=0)
                g[X][j]=min(g[1-X][j-v[y]]+f[y],g[X][j]);
        }
    }
    for(int i=0; i<v[x]+1; i++)
        f[x]=min(f[x],g[X][i]);
}
void init() {
    scanf("%d",&n);
    for(int i=2; i<=n; i++) {
        int p;
        scanf("%d",&p);
        addEdge(p,i);
    }
    for(int i=1; i<=n; i++)
        scanf("%d",&v[i]);
    memset(f,0x3f,sizeof(f));

}
void solve() {
    dfs(1);
}
void pri() {
    if(f[1]>=INF)
        printf("IMPOSSIBLE\n");
    else
        printf("POSSIBLE\n");
}
int main() {
    init();
    solve();
    pri();
    return 0;
}


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

ll n,a;
multiset<ll,greater<ll>>st;
map<ll,ll>mp;

int main(){
    cin>>n;
    rep(i,n){
        cin>>a;
        st.insert(a);
    }
    ll ans=0;
    while(!st.empty()){
        ll b=*st.begin(),x=1;
        while(x<=b)x*=2;
        st.erase(st.begin());
        if(st.find(x-b)!=st.end()){
            st.erase(st.find(x-b));
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 9600
#include<iostream>
using namespace std;
const int maxn = 1e5+10;
long long n, c, x[maxn], v[maxn], s1[maxn], s2[maxn];
int main()
{
	cin>>n>>c;
	for(int i=1; i<=n; i++) cin>>x[i]>>v[i];
	for(int i=1; i<=n; i++) s1[i] = s1[i-1] + v[i] - (x[i] - x[i-1]);
	x[n+1] = c;
	for(int i=n; i; i--) s2[i] = s2[i+1] + v[i] - (x[i+1] - x[i]);
	for(int i=2; i<=n; i++) s1[i] = max(s1[i-1], s1[i]);
	for(int i=n-1; i; i--) s2[i] = max(s2[i+1], s2[i]);
	long long ans = 0;
	for(int i=1; i<=n; i++) {
		ans = max(ans, s1[i] - x[i] + s2[i+1]);
		ans = max(ans, s2[i] - (c - x[i]) + s1[i-1]);
		ans = max(ans, s1[i]);
		ans = max(ans, s2[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3328