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

using namespace std;

typedef long long int64;
#define int long long
const int64 INF = 1LL << 59;

struct SegmentTree
{
  vector< int64 > small, add;
  int sz;


  inline void Merge(int k)
  {
    small[k] = min(small[2 * k + 1] + add[2 * k + 1], small[2 * k + 2] + add[2 * k + 2]);
  }

  SegmentTree(int n)
  {
    sz = 1;
    while(sz < n) sz <<= 1;
    small.assign(2 * sz - 1, INF);
    add.assign(2 * sz - 1, 0);
  }

  int64 rmq(int a, int b, int k, int l, int r)
  {
    if(a >= r || b <= l) return (INF);
    if(a <= l && r <= b) return (small[k] + add[k]);
    int64 L = rmq(a, b, 2 * k + 1, l, (l + r) >> 1);
    int64 R = rmq(a, b, 2 * k + 2, (l + r) >> 1, r);
    return (min(L, R) + add[k]);
  }


  int64 addd(int a, int b, int k, int l, int r)
  {
    if(a >= r || b <= l) return (0);
    if(a <= l && r <= b) return (add[k]);
    int64 L = addd(a, b, 2 * k + 1, l, (l + r) >> 1);
    int64 R = addd(a, b, 2 * k + 2, (l + r) >> 1, r);
    return (L + R + add[k]);
  }

  void rangeadd(int a, int b, int64 x, int k, int l, int r, bool f)
  {
    if(a >= r || b <= l) return;
    if(a <= l && r <= b) {
      if(f) small[k] = x;
      else add[k] += x;
      return;
    }
    rangeadd(a, b, x, 2 * k + 1, l, (l + r) >> 1, f);
    rangeadd(a, b, x, 2 * k + 2, (l + r) >> 1, r, f);
    Merge(k);
  }

  int64 rmq(int a, int b)
  {
    return (rmq(a, b, 0, 0, sz));
  }

  void rangeadd(int a, int b, int64 x, bool f)
  {
    return (rangeadd(a, b, x, 0, 0, sz, f));
  }


  void update(int a, int b, int64 x)
  {
    int64 q = addd(a, a + 1, 0, 0, sz);
    rangeadd(a, b, x - q, 1);
  }
};


signed main()
{
  int N, Q, A, B, X[200000];
  cin >> N >> Q >> A >> B;
  --A, --B;

  SegmentTree tree1(N), tree2(N);
  for(int i = 0; i < N; i++) tree1.rangeadd(i, i + 1, i, 0);
  for(int i = 0; i < N; i++) tree2.rangeadd(i, i + 1, -i, 0);
  for(int i = 0; i < Q; i++) cin >> X[i], --X[i];

  tree1.update(B, B + 1, abs(A - X[0]) + B);
  tree2.update(B, B + 1, abs(A - X[0]) - B);
  tree1.update(A, A + 1, abs(B - X[0]) + A);
  tree2.update(A, A + 1, abs(B - X[0]) - A);


  for(int i = 1; i < Q; i++) {
    int64 latte = tree1.rmq(X[i], N) - X[i];
    int64 malta = tree2.rmq(0, X[i]) + X[i];
    latte -= abs(X[i - 1] - X[i]);
    malta -= abs(X[i - 1] - X[i]);

    tree1.update(X[i - 1], X[i - 1] + 1, min(latte, malta) + X[i - 1]);
    tree2.update(X[i - 1], X[i - 1] + 1, min(latte, malta) - X[i - 1]);

    tree1.rangeadd(0, N, abs(X[i - 1] - X[i]), 0);
    tree2.rangeadd(0, N, abs(X[i - 1] - X[i]), 0);
  }

  int64 ret = INF;
  for(int i = 0; i < N; i++) ret = min(ret, tree1.rmq(i, i + 1) - i);
  for(int i = 0; i < N; i++) ret = min(ret, tree2.rmq(i, i + 1) + i);
  cout << ret << endl;
}

Measured memory_bytes: 18304
#include <stdio.h>
int main() {
    int n;
    scanf("%d", &n);
    int a[1000];
    for (int i = 0; i <n ; ++i) {
        scanf("%d", &a[i]);
    }
    int flag=0;
    for (int i = 0; i < n; ++i) {
        if (a[i] % 2 == 0) {
            flag++;
        }
    }
    int count=0;
    for (int i = 0; i <n ; ++i) {
        if (a[i] % 2 == 0){
            if(a[i]%3==0 || a[i]%5==0){
                count++;
            }
        }
    }
    if(flag==count){
        printf("APPROVED");
    }else{
        printf("DENIED");
    }
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <stdint.h>
#include <string.h>

uint32_t numList[100000];

int cmpfunc(const void * a, const void * b) {
	return *(uint32_t *)b - *(uint32_t *)a;
}

static uint32_t getCombDiff(const uint32_t i, const uint32_t j) {
	return j < i / 2 ? j : i - j;
}

static uint64_t calcComb(const uint64_t i, const uint64_t j) {
	uint64_t product = UINT64_C(1);

	for (uint64_t ii = 0; ii < j; ii++) {
		product *= i - ii;
	}
	for (uint64_t ii = 1; ii <= j; ii++) {
		product /= ii;
	}

	return product;
}

static void printMaxComb(const uint32_t * const numList, const uint32_t listSize) {
	uint32_t maxJ = 1;
	uint64_t maxComb = 0;
	uint32_t maxDiff = 0;

	for (uint32_t j = 1; j < listSize; j++) {
		const uint32_t diff = getCombDiff(numList[0], numList[j]);
		if (diff >= maxDiff) {
			maxDiff = diff;
		}
		else {
			maxJ = j - 1;
			break;
		}
	}

	printf("%"PRIu32" %"PRIu32, numList[0], numList[maxJ]);
}

int main(void) {
	uint32_t listSize;

	scanf("%"PRIu32"\n", &listSize);

	for (uint32_t idx = 0; idx < listSize - 1; idx++) {
		scanf("%"PRIu32" ", &(numList[idx]));
	}
	scanf("%"PRIu32, &(numList[listSize - 1]));

	qsort(numList, listSize, sizeof(uint32_t), cmpfunc);

	printMaxComb(numList, listSize);

	return 0;
}


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

double minkohu(int n, const double a[], const double b[],int p){
int i;
double A;
for(i = 0,A = 0; i < n;i++){
	A += pow( ( fabs(a[i] - b[i]) ) ,p);
}
return (pow(A, (double)1 / p));
}

double ch(int n,const double a[],const double b[])
{
	int i;
	double max = 0;
	for(i = 0; i < n; i++){
		if( max < fabs(a[i] - b[i]) )
			max = fabs(a[i] - b[i]);
	}
return max;
}



int main( void )
{
	int n, i;
	double a[128],b[128];
	
	scanf("%d",&n);
	
	for(i = 0; i < n; i++)
		scanf("%lf",&a[i]);
	for(i = 0; i < n; i++)
		scanf("%lf",&b[i]);
for(i = 1; i <= 3;i++)
	printf("%f\n",minkohu(n,a,b,i));
printf("%f\n",ch(n,a,b));

return 0;
}

Measured memory_bytes: 720
import java.util.Scanner;

public class Main {

	/**
	 * ???????????¢??°
	 *
	 * @param args
	 *            ?????¨?????????
	 */
	public static void main(String[] args) {
		Watch watch = null;
		try (Scanner sc = new Scanner(System.in)) {
			int initialValue = sc.nextInt();
			watch = new Watch(initialValue);
		}
		System.out.println(watch.getHour() + ":" + watch.getMinite() + ":" + watch.getSecond());
	}

	public static class Watch {
		private int hour;
		private int minite;
		private int second;

		/**
		 * ???????????????????§????????§£????????????????????? 24???????¶?????????¨0???????????????
		 *
		 * @param initialValue
		 */
		public Watch(int initialValue) {
			int work = initialValue;

			this.second = work % 60;
			work = work / 60;
			this.minite = work % 60;
			work = work / 60;
			this.hour = work % 24;
		}

		/**
		 * ?????????????????????
		 *
		 * @return ??????
		 */
		public int getHour() {
			return hour;
		}

		/**
		 * ??????????????????
		 *
		 * @return ???
		 */
		public int getMinite() {
			return minite;
		}

		/**
		 * ?§????????????????
		 *
		 * @return ?§?
		 */
		public int getSecond() {
			return second;
		}

	}

}

Measured memory_bytes: 26284
from itertools import accumulate


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def reset(self):
        self.tree = [0] * (self.size + 1)


def solve(n, aaa):
    t = n * (n + 1) // 4
    alt = sorted(set(aaa))
    l, r = 0, len(alt) - 1
    bt = Bit(n * 2)
    while l <= r:
        m = (l + r) // 2
        am = alt[m]
        ccc = accumulate(1 if a - am >= 0 else -1 for a in aaa)
        bt.add(n, 1)
        right_order = 0
        for p in ccc:
            p += n
            right_order += bt.sum(p)
            bt.add(p, 1)
        if right_order >= t:
            l = m + 1
        else:
            r = m - 1
        bt.reset()
    return alt[r]


n = int(input())
aaa = list(map(int, input().split()))
print(solve(n, aaa))


Measured memory_bytes: 89284
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
using namespace std;

int main(void){
    string s, t;
    int itchi = 0;
    cin >> s;
    t = "YAKI";
    if (s.size() < 4) cout << "No";
    else {
        for (int i = 0; i < 4; i++) {
            if (s[i] == t[i]) itchi++;
        }
        if (itchi == 4) cout << "Yes";
        else cout << "No";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

ll a,b,n;

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

    
    cin >> a >> b >> n;
    ll x = n;
    if(n>=b-1){ x = b-1 ;}
    cout << floor((a*x)/b)-a*floor(x/b) << endl;    


    return 0;
}

Measured memory_bytes: 3788
#include <stdio.h>
#define INF 1000000000
#define BLACK 1
#define WHITE 0
#define NIL -1

int G[101][101],d[101],pi[101],n,color[101],sum=0;

void prim(int);
int main(){
  int i,j;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      scanf("%d",&G[i][j]);
    }
  }
  prim(1);

  printf("%d\n",sum);

  return 0;
  
}

void prim(int r){
  int mincost,u,i,v;

  for(u=1;u<=n;u++){
    d[u]=INF;
    pi[u]=NIL;
    color[u]=WHITE;
  }
  d[r]=0;
  while(1){
    mincost=INF;
    for(i=1;i<=n;i++){
      if(color[i]!=BLACK && d[i]<mincost){
	mincost=d[i];
	u=i;
      }
    }
    if(mincost==INF) break;
    color[u]=BLACK;
    for(v=1;v<=n;v++){
      if(color[v]!=BLACK && G[u][v]<d[v] && G[u][v]!=-1){
	pi[v]=u;
	d[v]=G[u][v];
      }
    }

  }

  for(i=1;i<=n;i++){
    if(pi[i]!=NIL) sum=sum+G[i][pi[i]];
      
  

  }
}

Measured memory_bytes: 640
#pragma region Macros

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

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

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    int A, B;
    cin >> A >> B;

    int a = -1000000007;
    chmax(a, A + B);
    chmax(a, A - B);
    chmax(a, A * B);

    cout << a;
}

#pragma region main
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


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

int main(){
  string s;
  cin >> s;
  if (s[0] == s[1] && s[0] == s[2])
    cout << "Yes" << endl;
  else if (s[1] == s[2]  && s[1] == s[3])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
   return 0;
}



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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll find_nth(ll a, ll k) {
    if (k < a) return k;
    return k + 1;
}

ll prod_max(ll M, ll a, ll b) {
    vll tryA = { a - 1, a + 1 };
    for (ll i = M/2 - 5; i <= M/2 + 5; i++)
        tryA.push_back(i);

    ll res = 0;
    for (ll ar : tryA) if (ar != a) {
        ll wp = ar < a ? ar : ar - 1;
        if (wp > 0 && wp <= M) {
            ll br = find_nth(b, M + 1 - wp);
            res = max(res, ar * br);
        }
    }

    return res;
}

void solve() {
    int A, B;
    cin >> A >> B;

    ll T = ll(A) * B;

    ll ans = 0, lo = 1, hi = A + B;
    while (lo <= hi) {
        ll mi = (lo + hi) / 2;
        if (prod_max(mi, A, B) < T) {
            ans = mi;
            lo = mi + 1;
        } else {
            hi = mi - 1;
        }
    }

    cout << ans << "\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int Q;
    cin >> Q;
    for (int q = 0; q < Q; q++) {
        solve();
    }

    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int A = scan.nextInt();
    int B = scan.nextInt();
    if(A != 1 && B != 1){
      System.out.print(1);
    }
    else if(A != 2 && B != 2){
      System.out.print(2);
    }
    else if(A != 3 && B != 3){
      System.out.print(3);
    }
  }
}

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

int main(){
    ll n,m;
    cin >> n >> m;
    priority_queue <ll> q;
    ll ne;
    rep(i,n){
        cin >> ne;
        q.push(ne);
    }

    ll a;
    
    rep(i,m){
        a=q.top(); q.pop();
        q.push(a/2);
    }

    ll ans;
    ans=0;
    rep(i,n){
        a=q.top(); q.pop();
        ans+=a;
    }

    cout << ans << endl;
    

    

    return 0;
}

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

int main(){
	int x1[4] = {-1,0,0,1}, y1[4] = {0,1,-1,0};
	int x2[4] = {-1,-1,1,1}, y2[4] = {-1,1,-1,1};
	int x3[4] = {-2,0,0,2}, y3[4] = {0,-2,2,0};
	int p[10][10], x, y, s, nx, ny, maxl = 0, count = 0;
	for(int i = 0;i < 10;i++)
		for(int j = 0;j < 10;j++)p[i][j] = 0;
	char c;
	while(cin >> x >> c >> y >> c >> s){
		p[y][x]++;
		for(int i = 0;i < 4;i++){
			nx = x + x1[i];ny = y + y1[i];
			if(nx>=0&&nx<10&&ny>=0&&ny<10)p[ny][nx]++;
		}
		if(s > 1){
			for(int i = 0;i < 4;i++){
				nx = x + x2[i];ny = y + y2[i];
				if(nx>=0&&nx<10&&ny>=0&&ny<10)p[ny][nx]++;
			}
			if(s == 3){
				for(int i = 0;i < 4;i++){
					nx = x + x3[i];ny = y + y3[i];
					if(nx>=0&&nx<10&&ny>=0&&ny<10)p[ny][nx]++;
				}
			}
		}
	}
	for(int i = 0;i < 10;i++){
		for(int j = 0;j < 10;j++){
			maxl = max(maxl, p[i][j]);
			if(!p[i][j])count++;
		}
	}
	cout << count << endl << maxl << endl;
	return 0; 
}

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

struct Cube
{
	int f[6];
	Cube(){}

	void roll(int i,int j,int k,int l)
	{
		int t = f[i];
		f[i] = f[j];
		f[j] = f[k];
		f[k] = f[l];
		f[l] = t;
	}

	void roll_z() { roll(1,2,4,3); }
	void roll_y() { roll(0,2,5,3); }
	void roll_x() { roll(0,1,5,4); }

	void move(char c)
	{
		if(c == 'E') rep(i,3) roll_y();
		else if(c == 'W') roll_y();
		else if(c == 'N') roll_x();
		else if(c == 'S') rep(i,3) roll_x();
	}
};

bool equal_1(Cube c1,Cube c2)
{
	rep(i,6)
	{
		if(c1.f[i] != c2.f[i]) return false;
	}
	return true;
}

bool equal_2(Cube c1,Cube c2)
{
	rep(i,6)
	{
		rep(j,4)
		{
			if(equal_1(c1,c2)) return true;
			c1.roll_z();
		}
		if(i%2 == 0)
		{
			c1.roll_y();
		}
		else
		{
			c1.roll_x();
		}
	}
	return false;
}

int main()
{
	Cube c1,c2;

	rep(i,6) cin >> c1.f[i];
	rep(i,6) cin >> c2.f[i];

	if(equal_2(c1,c2))
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
//給料さえ分かればよい。ということは、わざわざ仕事の種類における給料は覚えておく必要がない！？
#include<iostream>
#define int long long
using namespace std;

int n, m;
int s[50001], t[50001], e[50001];		//5万+1行以下(職人s[i]が工事t[i]をe[i]回こなした)
int l;									//給料の算出回数(l <= 100)
int b[10000];							//b[i] = 職種jの単価
int c[10000];							//c[i] = 職人iの給料

signed main() {
	int i, j;
	cin >> n >> m;
	for(i = 0;;i++) {
		cin >> s[i] >> t[i] >> e[i];
		s[i]--; t[i]--;				//番号合わせ
		if( s[i] == -1 )
			break;
	}
	
	int kaisu = i;
	cin >> l;
	for( i = 0; i < l; i++ ) {
		for( j = 0; j < m; j++ ) {
			cin >> b[j];
		}
		for( j = 0; j < n; j++ ) {
			c[j] = 0;
		}
		for( j = 0; j < kaisu; j++ ) {
			c[ s[j] ] += b[ t[j] ] * e[j];
		}
		for( j = 0; j < n-1; j++ ) {
			cout << c[j] << " ";
		}
		cout << c[j] << endl;		//最後の要素の後ろには空白を入れない。
	}
	return 0;
}

Measured memory_bytes: 2484
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N;
  	int X;
  	int K;
  	int Y;
  	int SumB; /*宿泊費*前半*/
  	int SumA; /*宿泊費後半*/
    
  
  	cin >> N >> X >> K >> Y;
  	
  if(N - X > 0){
    	SumB =+ K * X;
  
    	SumA =+  Y * (N-X);
  	
  }
  else{
    	SumB =+ N * K;
  }
  
  cout << SumA + SumB << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
typedef long long ll;
int main() 
{ 
	int n;
  	cin >> n;
  	int sum = 0 , i = 0;
  	while(sum < n){
  		i++;
		sum += i;
      	
    }
  	cout << i << endl;  
	return 0; 
} 

Measured memory_bytes: 256
#include<stdio.h>

using namespace std;
int main(){
    int H,W;
    while(true){
        scanf("%d %d",&H,&W);
        if (H==0 && W==0){
            break;
        }
        for (int i=0; i<H; i++){
            for (int k=0; k<W; k++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2592
#include <stdio.h>
int main(void){
    int h, n;
    scanf("%d%d", &h, &n);
    int a[n];
    for (int i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }

    for (int i = 0; i < n; i++){
        h -= a[i];
    }
    if (h <= 0){
        printf("%s\n", "Yes");
    }
    else {
        printf("%s\n", "No");
    }

    return 0;
}


Measured memory_bytes: 512
def resolve():
    import sys
    input = sys.stdin.readline
    nmk = [int(x) for x in input().rstrip().split(" ")]
    n = nmk[0]
    m = nmk[1]
    k = nmk[2]
    a_list = [int(x) for x in input().rstrip().split(" ")]
    b_list = [int(x) for x in input().rstrip().split(" ")]

    from collections import deque
    qa = deque()
    qb = deque()
    total_min = 0
    for i in range(len(a_list)):
        if a_list[i] + total_min <= k:
            qa.append(a_list[i])
            total_min += a_list[i]
        else:
            break
    

    
    max_book = len(qa)

    for i in range(len(qb), len(b_list)):
        if b_list[i] + total_min <= k:
            qb.append(b_list[i])
            total_min += b_list[i]
        else:
            break
    if len(qa) + len(qb) > max_book:
        max_book = len(qa) + len(qb)

    while len(qa) > 0:
        poped = qa.pop()
        total_min -= poped
    
        for i in range(len(qb), len(b_list)):
            if b_list[i] + total_min <= k:
                qb.append(b_list[i])
                total_min += b_list[i]
            else:
                break
        if len(qa) + len(qb) > max_book:
            max_book = len(qa) + len(qb)
    
    print(max_book)
        

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 114084
"""
日本でよく使われる紙幣は、10000円札、5000円札、1000円札です。
以下、「お札」とはこれらのみを指します。

青橋くんが言うには、彼が祖父から受け取ったお年玉袋には、
お札がN枚入っていて、合計でY円だったそうですが、嘘かもしれません。
このような状況がありうるか判定し、ありうる場合はお年玉袋の中身の候補を一つ見つけてください。
なお、彼の祖父は十分裕福であり、お年玉袋は十分大きかったものとします。

入力は以下の形式で標準入力から与えられる。
>>> N Y
"""

lis = input().split()
N, Y = [int(x) for x in lis]

# 10000円札、5000円札、1000円札がそれぞれA, B, C枚とする。
maxA = min(Y // 10000, N)
bl = True

for A in range(maxA + 1):
    d = Y - 10000 * A
    n = N - A
    
    """ 
    この時、解くべき連立方程式
    B + C = n
    5000 * B + 1000 * C = d
    であり、これを解くと
    B = (d - 1000 * n) / 4000
    C = (5000 * n - d) / 4000
    """
    B_times_4k = d - 1000 * n
    C_times_4k = 5000 * n - d
    
    cond1 = B_times_4k * C_times_4k >= 0
    cond2 = B_times_4k % 4000 == 0

    if cond1 and cond2:
        B = B_times_4k // 4000
        C = C_times_4k // 4000
        print('{} {} {}'.format(A, B, C))
        bl = False
        break

if bl:
    print('-1 -1 -1')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;  
using namespace std;

typedef long long ll;

typedef tree<
pair <int, int>,
null_type,
less<pair <int, int>>,
rb_tree_tag,
tree_order_statistics_node_update>
os;

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

const int N = 2e5 + 5;
const ll MOD = 1e9 + 7;

ll f[N];
ll inv[N];

ll get(ll a, ll b) {
  ll res = 1ll;
  while(b) {
    if(b & 1) res = (res * a) % MOD;
    b >>= 1;
    a = (a * a) % MOD;
  }
  return res;
}

ll ncr(ll n, ll r) {
  if(n < r or n < 0 and r < 0) return 0;
  ll cur = f[n];
  cur = (cur * inv[r]) % MOD;
  cur = (cur * inv[n - r]) % MOD;
  return cur;
}

int main() {
  string s, t; cin >> s >> t;
  int n = s.length();
  vector <int> a(500, 0), b(500, 0);
  for(int i = 0; i < n; i++) {
    int x = s[i], y = t[i];
    if(a[x] or b[y]) {
      if(a[x] != y or b[y] != x) {
        print("No");
        return 0;
      }
    }
    else {
      a[x] = y, b[y] = x;
    }
  }
  print("Yes");
}

Measured memory_bytes: 776
#include <iostream>
using namespace std;
#define MAX 100000

int parent(int i) {return i / 2;}
int left(int i) {return 2 * i;}
int right(int i) {return 2 * i + 1;}

int main() {
    int H, i, A[MAX + 1];

    cin >> H;
    for ( i = 1; i <= H; i++) cin >> A[i];
    
    for ( i = 1; i <= H; i++){
        cout << "node " << i << ": key = " << A[i] << ", ";
        if (parent(i) >= 1) cout << "parent key = " << A[parent(i)] << ", ";
        if (left(i) <= H) cout << "left key = " << A[left(i)] << ", ";
        if (right(i) <= H) cout << "right key = " << A[right(i)] << ", ";
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3072
#include<iostream>

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

	int t;
	if (a > b) {
		t = a;
		a = b;
		b = t;
	}
	if (b > c) {
		t = b;
		b = c;
		c = t;
	}
	if (a > b) {
		t = a;
		a = b;
		b = t;
	}
	std::cout << a << " " << b << " " << c << std::endl;
}

Measured memory_bytes: 1164
a = []
for i in range(3):
    a.append(list(map(int, input().split())))

N =int(input())
b = []
for i in range(N):
    b.append(int(input()))

check=[]
for i in range(3):
    for k,number in enumerate(a[i]):
        if number in b:
            check.append(1)
        else:
            check.append(0)

bingo_check=0
if check[0]==1:
    if check[1]==1 and check[2]==1:
        bingo_check=1
    elif check[3]==1 and check[6]==1:
        bingo_check=1
    elif check[4]==1 and check[8]==1:
        bingo_check=1
if check[1]==1:
    if check[4]==1 and check[7]==1:
        bingo_check=1
if check[2]==1:
    if check[5]==1 and check[8]==1:
        bingo_check=1
    elif check[4]==1 and check[6]==1:
        bingo_check=1
if check[3]==1:
    if check[4]==1 and check[5]==1:
        bingo_check=1

if check[6]==1:
    if check[7]==1 and check[8]==1:
        bingo_check=1


if bingo_check==1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include"bits/stdc++.h"

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7

void add(vector<ll>& data, vector<ll>& datb, ll a, ll b, ll x, ll k, ll l, ll r)
{
	if(a <= l && r <= b)
	{
		data[k] = (data[k] + x) % MOD;
	}
	else if(l < b && a < r)
	{
		datb[k] = (datb[k] + (min(b, r) - max(a, l))*x) % MOD;
		add(data, datb, a, b, x, k * 2 + 1, l, (l + r) / 2);
		add(data, datb, a, b, x, k * 2 + 2, (l + r) / 2, r);
	}
}

ll sum(vector<ll>& data, vector<ll>& datb, ll a, ll b, ll k, ll l, ll r)
{
	if(b <= l || r <= a)return 0;
	if(a <= l && r <= b)return data[k] * (r - l) + datb[k];

	ll res = (min(b, r) - max(a, l))*data[k] % MOD;
	res = (res + sum(data, datb, a, b, k * 2 + 1, l, (l + r) / 2)) % MOD;
	res = (res + sum(data, datb, a, b, k * 2 + 2, (l + r) / 2, r)) % MOD;
}

//メイン関数
int main()
{
	constexpr int DATSIZE = (1 << 18) - 1;
	// input
	ll N, K;
	cin >> N >> K;
	vector<ll>a(N);
	vector<vector<ll>> dp(N + 1, vector<ll>(K + 2, 0));
	REP(i, N)cin >> a[i];

	// init
	dp[0][0] = 1;

	// dp with special Binary Indexed Tree
	REP(i, N)
	{
		REP(j, K + 1)
		{
			ll way = dp[i][j];
			dp[i + 1][j] = (dp[i + 1][j] + way) % MOD;
			dp[i + 1][min(j + a[i] + 1, K + 1)] = (dp[i + 1][min(j + a[i] + 1, K + 1)] - way + MOD) % MOD;
		}
		REP(j, K + 1)dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i + 1][j]) % MOD;
	}
	cout << dp[N][K] % MOD << endl;
	cin >> N;

	return 0;
}


Measured memory_bytes: 80256
using System;


public class B{
	
	public static void Main(){
	
		string[] args = Console.ReadLine().Split(' ');
		long n = Int64.Parse(args[0]);
		
		bool result = false;
		for( long i = 0L; i <= n/7L; i++ ){
			long rest = n - 7L * i;
			if( rest % 4L == 0L ){
				result = true;
				break;
			}
		}
		Console.WriteLine( result ? "Yes" : "No" );
		
	}

}

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

#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define rev(v) reverse(v.begin(), v.end());
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

signed main(){
    io();
    char c; cin >> c;
    ++c;
    cout << char(c) << '\n';
    return 0;
}

Measured memory_bytes: 3524
#include <stdio.h>

int main(){
  int n;  scanf("%d", &n);
  long long int lucas[90];
  lucas[0] = 2, lucas[1] = 1;
  for(int i=2; i<=n; i++)
    lucas[i] = lucas[i-1] + lucas[i-2];

  printf("%lld\n", lucas[n]);
  return 0;
}


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

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
double pi=acos(-1);
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
// #define mp make_pair
#define pq priority_queue
const ll mod=1000000007;
#define f first
#define s second
#define pii pair< ll, ll >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace boost::multiprecision;
using namespace std;
void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}


const int N=1000005;
ll fact[N],invfact[N];
ll power(ll x,ll y){
  if(y<=0) return 1LL;
  ll z=power(x,y/2);
  if(y%2) return (((z*z)%mod)*x)%mod;
  return (z*z)%mod;
}

void pre(){
  fact[0]=invfact[0]=invfact[1]=fact[1]=1;
  rep(i,2,N) fact[i]=(i*fact[i-1])%mod;
  rep(i,2,N) invfact[i]=(invfact[i-1]*power(i,mod-2))%mod;
}
ll nCr(ll n,ll k){ return (((fact[n]*invfact[n-k])%mod)*invfact[k])%mod; }



const int N1=1e6+1;
vector<int> isprime(N1,1),prime;
void seive(){
  rep(i,2,sqrt(N1)+1){
      if(isprime[i]){
        for(int j=i*i;j<N1;j+=i) isprime[j]=0;
        prime.pb(i);
      }
  }
  rep(i,sqrt(N1)+1,N1) if(isprime[i]) prime.pb(i);
}



struct dsu {
    vector<int> par, rank;
    dsu(int n): par(n+1), rank(n+1) {
        for (int i = 0; i <= n; i++) {
            par[i] = i;
            rank[i]= 1;
        }
    }
    int root(int a) {
        if (a == par[a]) return a;
        return par[a] = root(par[a]);
    }
    void merge(int a, int b) {
        a = root(a);
        b = root(b);
        if (a == b) return;
        if (rank[a] > rank[b]) swap(a, b);
        par[b] = a;
    }
    set<int> parent(int n){
        set<int> s;
        for(int i=1;i<=n;i++){
            s.insert(root(i));
        }
        return s;
    }
};

void solve(){
  string s;
  cin>>s;
  s[3]='8';
  cout<<s<<endl;
}

int main(){
    optimizeIO();
    int r=1;
    {solve();}
}


Measured memory_bytes: 7032
#include <bits/stdc++.h>
using namespace std;
using P = pair<int,int>;

int main(){
  int n, m;
  cin >> n >> m;
  vector<P> aru(n);
  for(int i=0; i<n; ++i){
    int a, b;
    cin >> a >> b;
    aru[i] = make_pair(a,b);
  }
  sort(aru.begin(),aru.end());
  int ans = 0;
  int arui = 0;
  priority_queue<int> que;
  for(int i=1; i<=m; ++i){
    //cout << i << ':';
    while(arui < n && i == aru[arui].first){
      que.push(aru[arui].second);
      //cout << aru[arui].second << " ";
      ++arui;
    }
    //cout << endl;
    if(!que.empty()){
      ans += que.top();
      que.pop();
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4612
#include <cstdio>

int main()
{
  int num, now, i, top = 0, res = 0;
  scanf("%d", &num);
  for(i = 0; i < num; i++){
    scanf("%d", &now);
    if(now >= top){
      res++;
      top = now;
    }
  }
  printf("%d\n", res);
  return  0;
}

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

int main(){
  int N, X, mi=1000000;
  cin >> N >> X;
  vector<int> m(N);
  for(int i=0;i<N;i++){
    cin >> m[i];
    X -= m[i];
    mi = min(mi,m[i]);
  }
  cout << N+(X/mi) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    #include <set>
    #define REP(i, n) for(int i = 0;i < n;i++)
    #define REPR(i, n) for(int i = n;i >= 0;i--)
    #define FOR(i, m, n) for(int i = m;i < n;i++)
    #define FORR(i, m, n) for(int i = m;i >= n;i--)
    #define SORT(v, n) sort(v, v+n);
    #define VSORT(v) sort(v.begin(), v.end());
    //
    #define llong long long
    #define pb(a) push_back(a)

    #define INF 100000000
    #define MOD 100000007

    #define writeln(n) cout<<n<<endl

    using namespace std;
    typedef pair<int, int> P;
    typedef pair<llong, llong> LP;
    typedef pair<int, P> PP;
    typedef pair<llong, LP> LPP;
    //vector<tuple<long long, long long, long long>>vec;


    bool isprime(int p) {
        if (p == 1) return false;
        for (int i = 2; i < p; i++) {
            if (p%i == 0) return false;
        }
        return true;
    }

    int dx[4] = {1, 0, -1, 0};
    int dy[4] = {0, 1, 0, -1};

    const int inf=100000000;

    long long modpow(long long a, long long n, long long mod) //a^n
    {
        long long res = 1;
        while (n > 0) {
            if (n & 1) res = res * a % mod;
            a = a * a % mod;
            n >>= 1;
        }
        return res;
    }

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

    //素数判定
    bool isprime(llong p) {
        if (p == 1) return false;
        for (llong i = 2; i*i <= p; i++) {
            if (p%i == 0) return false;
        }
        return true;
    }


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

        int n; cin>>n;
        if(n%2==0) cout<<0.5<<endl;
        else {
            if (n == 1) cout << 1 << endl;
            else cout << setprecision(10) <<(double) (n - (n / 2)) / n << endl;
        }
        return  0;
    }


Measured memory_bytes: 256
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
 
using namespace std;
int MOD = 1000000007;

signed main(){
    int n;
    cin >> n;
    int ans = INF;
    int a,b,c;
    cin >> a >> b >> c;
    vector<int> l(n);
    rep(i,n)cin >> l[i];
   
    SORT(l);

    do{
        int cnt[3] = {0};
        int S[10] = {0};
        rep(i,n)S[i+1] = S[i] + l[i];
        int s[3] = {0};
        for(int i = 0;i<n-2;i++){
            for(int j = i+1;j<n-1;j++){
                for(int k = j+1;k<n;k++){
                    cnt[0] = 10*(i+1-1);
                    cnt[1] = (j-i-1)*10;
                    cnt[2] = (k-j-1)*10;
                    s[0] = abs(S[i+1]-a);
                    s[1] = abs(S[j+1]-S[i+1]-b);
                    s[2] = abs(S[k+1]-S[j+1]-c);
                    ans = min(ans,cnt[0]+cnt[1]+cnt[2]+s[0]+s[1]+s[2]);
                }
            }
        }
    } while (std::next_permutation(l.begin(), l.end()));
    cout << ans << endl;

    return 0;   
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://abc119.contest.atcoder.jp/tasks/abc119_a
// rm -r -f test;oj dl http://yahoo-procon2017-qual.contest.atcoder.jp/tasks/yahoo_procon2017_qual_c

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

int main(){
  string s;
  cin >> s;
  if(s[0]==s[1]){
    if(s[2]==s[3]&&s[2]!=s[0])
      cout << "Yes";
    else
      cout << "No";
  }
  
  else if(s[0]==s[2]){
    if(s[1]==s[3]&&s[1]!=s[0])
      cout << "Yes";
    else
      cout << "No";
  }
  
  else if(s[0]==s[3]){
    if(s[2]==s[1]&&s[2]!=s[0])
      cout << "Yes";
    else
      cout << "No";
  }
  
  else
    cout << "No";
  
  return 0;
}


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

int main() {
    int n, ans = 0;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p.at(i);
    rep(i, n - 2) if(min(p.at(i), min(p.at(i + 1), p.at(i + 2))) != p.at(i + 1) && max(p.at(i), max(p.at(i + 1), p.at(i + 2))) != p.at(i + 1)) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

int main()
{
    int n;
    cin >> n;
    int dp[n][3];
    for (int q = 0; q < n; q++)
    {
        int a,b,c;
        cin >> a >> b >> c;
        if (q==0)
        {
            dp[q][0] = a;
            dp[q][1]=b;
            dp[q][2]=c;
        }
        else
        {
            dp[q][0]=a+max(dp[q-1][1], dp[q-1][2]);
            dp[q][1]=b+max(dp[q-1][0], dp[q-1][2]);
            dp[q][2]=c+max(dp[q-1][0], dp[q-1][1]);
        }
    }
    int maxx = dp[n-1][0];
    maxx = max(maxx, dp[n-1][1]);
    maxx = max(maxx, dp[n-1][2]);
    cout << maxx;
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll N;
  std::cin >> N;
  std::vector< ll > va(N, 0LL);

  ll max1_val  = -1;
  ll max2_val = -1;
  
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i];
    if (va[i] >= max2_val) {
      if (va[i] >= max1_val) {
	max2_val = max1_val;
	max1_val = va[i];
      } else {
	max2_val = va[i];
      }
    }
  }

  for (std::vector< ll >::iterator it = va.begin(); it != va.end(); it++) {
    ll value = max1_val;
    if (*it == max1_val) value = max2_val;
    print(value);
  }

  return 0;
}


Measured memory_bytes: 3200
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N, M; cin >> N >> M;
	vector<int>L(M), R(M); rep(i, 0, M) { cin >> L[i] >> R[i];}

	int LL = 1e5 + 10;
	vector<int>imos(LL);
	rep(i, 0, M) {
		imos[L[i]]++;
		imos[R[i] + 1]--;
	}

	int ans = 0;
	rep(i, 1, N + 1) {
		imos[i] += imos[i - 1];
		if (imos[i] == M) {
			ans++;
		}
	}
	cout << ans << endl;



	return 0;
}


Measured memory_bytes: 2560
K = int(input())
S = lambda n: sum(map(int,str(n)))
R = lambda n: n/S(n)

arr = []
for i in range(1,1000):
    for j in range(1,15):
        arr.append(int(str(i) + '9'*j))

arr.sort(reverse=True)
min_r = arr[0]
snukes = []
for a in arr:
    r = R(a)
    if r < min_r:
        min_r = r
        snukes.append(a)

for i in range(min(9,K)):
    print(i+1)
if K <= 9:
    exit()
K -= 9

print(*snukes[:-K-1:-1],sep='\n')

Measured memory_bytes: 3696
S = input()
ans = 0

if S == 'SUN':
    ans = 7
elif S == 'MON':
    ans = 6
elif S == 'TUE':
    ans = 5
elif S == 'WED':
    ans = 4
elif S == 'THU':
    ans = 3
elif S == 'FRI':
    ans = 2
elif S == 'SAT':
    ans = 1

print(ans)

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

int main (){
    int a, b, r,d;
    double f; 
    cin >> a >> b;
    d = a/b;
    r = a%b;
    f = (double) a/b;
    cout << d << " " << r << " " << fixed << f <<endl;
    return 0;}



Measured memory_bytes: 3268
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  ll n; cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  ll ans=0;
  rep(i,n){
    if(i>0&&a[i-1]==1&&a[i]>0){
      ans++;
      a[i-1]=0; a[i]--;
    }
    ans+=a[i]/2;
    a[i]=a[i]-a[i]/2*2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
S = input()
week = ["SUN","MON","TUE","WED","THU","FRI","SAT"]

if S == week[0]:
  print(7)
elif S == week[1]:
  print(6)
elif S == week[2]:
  print(5)
elif S == week[3]:
  print(4)
elif S == week[4]:
  print(3)
elif S == week[5]:
  print(2)
else:
  print(1)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iomanip>


#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;


// <<fixed<<setprecision(6)<<


int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}


int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}


int main(){
  int y;
  string s;
  cin>>y>>s;
  int n=s.size();
  rep(i,n){
    char j;
    j=s[i];
    j+=y;
    if(j>90){
      j-=26;
    }
    cout<<j;
  }
}

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


class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int n=sc.nextInt();
        int[]a=new int[n],b=new int[n];
        //policy-2
        int[]p2=new int[2*n];
        for(int i=0;i<n;++i){
            a[i]=sc.nextInt();
            b[i]=sc.nextInt();
            p2[2*i]=2*a[i]+1;
            p2[2*i+1]=2*b[i];
        }
        //policy-2
        Arrays.sort(p2);
        int ans2=0;
        int c=0;
        for(int i=0;i<2*n;++i){
            if(p2[i]%2==0)
                c--;
            else
                c++;
            ans2=Math.max(ans2,c);
        }
        //policy-1
        int ans1=0;
        PlusSegmentTree segL=new PlusSegmentTree();
        PlusSegmentTree segR=new PlusSegmentTree();
        for(int i=0;i<n;++i){
            segL.update(a[i],segL.query(a[i],a[i]+1)+1);
            segR.update(b[i],segR.query(b[i],b[i]+1)+1);
        }
        for(int i=0;i<n;++i){
            int u=(int)segL.query(1,b[i]);
            u-=(int)segR.query(1,a[i]+1);
            ans1=Math.max(ans1,u);
        }
        if(ans1<ans2)throw new Error();
        out.println(ans1+" "+ans2);
        out.close();
    }
    // http://codeforces.com/blog/entry/7018
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}
class PlusSegmentTree {
    static final int SIZE = 1 << 18;
    long[] seg;
    PlusSegmentTree() {
	this.seg = new long[2 * SIZE];
    }
    void update(int x, long value) {
	x += SIZE - 1;
	this.seg[x] = value;
	while (x > 0) {
	    x = (x - 1) / 2;
	    this.seg[x] = this.seg[2 * x + 1] + this.seg[2 * x + 2];
	}
    }
    long query(int l, int r) {
	l += SIZE - 1;
	r += SIZE - 1;
        long y = 0;
	while (l < r) {
	    if ((l & 1) == 0) {
		y = y + this.seg[l];
	    }
	    if ((r & 1) == 0) {
		y = y + this.seg[r - 1];
	    }
	    l /= 2;
	    r = (r - 1) / 2;
	}
	return y;
    }
}

Measured memory_bytes: 71932
#include <cstdio>
 

int n, m;
int l[30];
int a[30][30];
int d;
int count;
 
void solve() {
  for (int i = 1; i <= m; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < l[j]; k++) {
        if (a[j][k] == i) {
          count += 1;
        }
      }
    }
    if (count == n) {
      d += 1;
    }
    count = 0;
  }
}
 
int main() {
  scanf("%d", &n);
  scanf("%d", &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &l[i]);
    for (int j = 0; j < l[i]; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  solve();
  printf("%d\n", d);
 
  return 0;
}


Measured memory_bytes: 128
/*
      author : nishi5451
      created: 11.08.2020 23:12:20
*/

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


int main(){
    int s,w;
    cin >> s >> w;
    if(w>=s) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <stdlib.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <utility>
using namespace std;


int main() {
	int N, M;
	scanf("%d %d", &N, &M);
    int H[100010];
	for (int i=1; i <= N; i++) {
        scanf("%d", &H[i]);
    }
    int n[100010];
    for (int i=1; i <= N; i++) {
        n[i] = i;
    };
    for (int i=0; i < M; i++) {
        int A, B;
        scanf("%d %d", &A, &B);
        if (H[A] == H[B]) {
            n[A] = 0;
            n[B] = 0;
        } else if (H[A] > H[B]) {
            n[B] = 0;
        } else {
            n[A] = 0;
        }

    }
    int count = 0;
    for (int i=1; i <= N; i++) {
        if (n[i] != 0) {
            count++;
        }
    }
	printf("%d\n", count);
	
	return 0;
}

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

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

    int N;
    std::cin >> N;

    std::vector<int> h(N);
    std::vector<int> dp(N);

    for (int i = 0; i < N; ++i)
        cin >> h[i];

    for (int i = 1; i < N; ++i)
    {
        if (i - 1 >= 0)
            dp[i] = abs(h[i] - h[i - 1]) + dp[i - 1];
        if (i - 2 >= 0)
            dp[i] = min(dp[i], abs(h[i] - h[i - 2]) + dp[i - 2]);
    }

    cout << dp[N - 1] << '\n';

    return 0;
}

Measured memory_bytes: 1024