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

int main() {
 	    long n;
         cin>>n;
        long ar[n][3]={};
        for(long i=0;i<n;i++){
            cin>>ar[i][0]>>ar[i][1]>>ar[i][2];
        }
        //we need to compute each day possibilt for when eacah act was chosen
        //greedy cant help here
        long dp[n][3]; //dp[i][0] means inclding best points possibe upto day (i-1) + first choice at day i //here day is from 0 to n-1
        dp[0][0]=ar[0][0];
        dp[0][1]=ar[0][1];
        dp[0][2]=ar[0][2];
        for(int i=1;i<n;i++){
              for(int j=0;j<3;j++){
                  dp[i][j]=ar[i][j]+max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]); //%3 helps select 2 other j's other than current j
              }
        }
        cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));


	return 0;
}

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

typedef long long ll;
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define rerepi(i, a, b) for(ll i = ll(a)-1; i >= b; --i)
#define rerep(i, n) rerepi(i, n, 0)

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; }
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) {o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const long long INF = 1LL << 60;

// 降順ソート
// std::sort(data.begin(),data.end(),std::greater<ll>());
// 昇順ソート
// std::sort(data.begin(),data.end());

// vector型の「data」に xが存在するかを、True or Falseで返す
// vector_finder(data, x)
bool vector_finder(std::vector<ll> vec, ll number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
  }
  else { // 発見できなかったとき
    return false;
  }
}

// ここから開始だよ！
ll N, X;
std::vector<ll> ALL;
std::vector<ll> NIKU;

ll run(ll N, ll X) {
  ll ans = 0;
  
  if (N == 0) {
    return 1;
  }
  
  if (X >= 1) {
    X--;
  }
  
  if (X >= 1) {
    if (ALL[N-1] <= X) {
      X -= ALL[N-1];
      ans += NIKU[N-1];
    } else {
      ans += run(N-1, X);
      X = 0;
    }
  }
  
  if (X >= 1) {
    X--;
    ans++;
  }
  
  if (X >= 1) {
    if (ALL[N-1] <= X) {
      X -= ALL[N-1];
      ans += NIKU[N-1];
    } else {
      ans += run(N-1, X);
      X = 0;
    }
  }
  
  if (X >= 1) {
    X--;
  }
  
  return ans;
}

int main() {
	// 呪文エリア
	cin.tie(0);
	ios::sync_with_stdio(false);
	// 詠唱完了
	
	cin >> N >> X;
	ALL.push_back(1);
  NIKU.push_back(1);
	
	repi(i, 1, N+1){
		ALL.push_back((ALL[i-1] * 2) + 3);
    NIKU.push_back((NIKU[i-1] * 2) + 1);
	}
	
	cout << run(N, X) << endl;
	
	return 0;
}


Measured memory_bytes: 256
N=int(input())

#753数を列挙してその数を数える
def dfs(s):
  #Nを超えたらカウントしない
  if int(s)>N:
    return 0
  #sに7,5,3の全てが含まれているなら+1
  ret = 1 if all(s.count(c)>0 for c in '753') else 0
  for c in '753':
    #sに7or5or3を加えてdfs
    ret += dfs(s + c)
  return ret

#0から始める
print(dfs('0'))

#難しい...

Measured memory_bytes: 2940
#include<stdio.h>
int main(){
	int i,j,kari;
	long long int a[3];
	for(i=0;i<3;i++){
		scanf("%lld",&a[i]);
	}
	for(i=0;i<3;i++){
		for(j=i+1;j<3;j++){
			if(a[i]>a[j]){
				kari=a[i];
				a[i]=a[j];
				a[j]=kari;
			}
		}
	}
	for(i=0;i<3;i++){
		printf("%lld",a[i]);
				if(i<2){printf(" ");}else{printf("\n");}
	}
	return 0;
}

Measured memory_bytes: 1804
q = int(input())
ab = [tuple(map(int, input().split())) for _ in range(q)]



for a, b in ab:
    if a > b:
        large = a
        small = b
    elif a < b:
        large = b
        small = a
    else:
        print(2* a - 2)
        continue


    # 最大のxを探す
    low_x = 0 
    upper_x = large - small + 1

    while upper_x- low_x> 1:
        mid_x = (low_x + upper_x ) //2

        # a * bを満たすかチェック
        is_ok = True
        for i in range(mid_x // 2 -2, mid_x //2 +3) :
            if i< 0 and b -a < i:
                continue
            if (small + i) * (small + mid_x - i) >= large* small:
                is_ok = False
                break

        if is_ok:
            low_x = mid_x
            x = mid_x
        else:
            upper_x = mid_x
            x= mid_x


    print(2 * small -2  + low_x)


Measured memory_bytes: 3064
#include<stdio.h>

int main()
{
     long long  int n,k,c=0,a=1;
    scanf("%lld %lld",&n,&k);
    for(;a!=0;)
    {
        a=n/k;
        n=a;
        c++;
    }


printf("%lld\n",c);

}

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  REP(i, n) cin >> d[i];
  sort(ALL(d));
  cout << d[n / 2] - d[n / 2 - 1] << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0; i<(int)n; i++)
#define rep2(i,a,n) for(long long i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const ll mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}

ll N, M, K, H, W, L, R, X;
string S, T;

int main(){
  string march = "MARCH";
  cin >> N;
  map<char, ll> mp;
  rep(i, N){
    string s; cin >> s;
    rep(j,5){
      if(s[0]==march[j]){mp[s[0]]++; break;}
    }
  }
  ll ans = 0;
  int cnt = mp.size();
  if(cnt <= 2){ cout << 0 << endl; return 0;}
  else if(cnt >= 3){
    for(auto itr1 : mp){
      for(auto itr2 : mp){
        if(itr2 <= itr1) continue;
        for(auto itr3 : mp){
          if(itr3 <= itr2) continue;
          ans += itr1.second*itr2.second*itr3.second;
        }
      }
    }
    cout << ans << endl;
    return 0;
  }

  return 0;
}

Measured memory_bytes: 3608
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

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

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll A, B;
  cin >> A >> B;
  if (A <= 0 && 0 <= B) {
    cout << "Zero" << endl;
    return 0;
  }

  if (A < 0 && 0 < B) {
    if (A % 2 != 0) {
      cout << "Positive" << endl;
    } else {
      cout << "Negative" << endl;
    }
    return 0;
  }

  if (A < 0 && B < 0) {
    if ((B - A) % 2 != 0) {
      cout << "Positive" << endl;
    } else {
      cout << "Negative" << endl;
    }
    return 0;
  }

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


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

int main() {
	int D, T, S;
	cin >> D >> T >> S;
	if (D <= T * S) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}



	return 0;
}



Measured memory_bytes: 3592
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()
 
n,m = na()
a=1
b=n
for i in range(m):
    l,r = na()
    a=max(a,l)
    b=min(b,r)

print(max(b-a+1,0))

Measured memory_bytes: 3064
#include <iostream>
#include<string.h>
#include<algorithm>
#include<math.h>

using namespace std;

int main() {
	int A, B, C,X;
	cin >> A >> B >> C >> X;
	int count = 0;

	for (int a = 0; a <= A; ++a) {
		for (int b = 0; b <= B; ++b) {
			for (int c = 0; c <= C; ++c) {
		
				if (X == 500 * a + 100 * b + 50 * c) {
					count = count + 1;
			     }			
			}
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
import collections
n = int(input())
a = list(map(int,input().split()))
ac = collections.Counter(a)
ac = list(ac.items())
ac.sort()
# print(ac)

mod = int(1e9+7)
ans = 1
if n % 2 == 0:
    for i in range(1,n,2):
        if ac[i//2][0] != i or ac[i//2][1] != 2:
            print(0)
            exit()
        else:
            ans *= 2
            ans %= mod
else:
    for i in range(0, n, 2):
        if i == 0:
            if ac[i//2][0] != i or ac[i//2][1] != 1:
                print(0)
                exit()
        else:
            if ac[i//2][0] != i or ac[i//2][1] != 2:
                print(0)
                exit()
            else:
                ans *= 2
                ans %= mod
print(ans)




Measured memory_bytes: 56812
///
// File:  cgl_1_b.cpp
// Author: ymiyamoto
//
// Created on Sun Oct 22 19:02:33 2017
//

#include <cstdint>
#include <iomanip>
#include <iostream>

using namespace std;

struct vector_t {
  double x;
  double y;

  vector_t(double a, double b) : x(a), y(b)
  {
  }

  double norm2()
  {
    return x * x + y * y;
  }

  double cross(vector_t a)
  {
    return x * a.x + y * a.y;
  }

  vector_t operator*(double a)
  {
    return vector_t(a * x, a * y);
  }
};

struct point_t {
  double x;
  double y;

  point_t operator+(const point_t a)
  {
    return point_t({x + a.x, y + a.y});
  }

  void print()
  {
    cout << fixed << setprecision(10) << x << " " << y << endl;
  }

  point_t operator+(const vector_t vec)
  {
    return point_t({x + vec.x, y + vec.y});
  }

  point_t operator-(const point_t p)
  {
    return point_t({x - p.x, y - p.y});
  }

  point_t reflect(point_t p1, point_t p2)
  {
    vector_t vec1(x - p1.x, y - p1.y);
    vector_t vec2(p2.x - x, p2.y - y);
    return point_t({x, y}) + vec1 * (vec1.cross(vec2) / vec1.norm2());
  }
};

int32_t main()
{
  double x, y;
  cin >> x >> y;
  point_t p = point_t({x, y});

  cin >> x >> y;
  point_t p1 = point_t({x, y});

  uint32_t q;
  cin >> q;
  for (uint32_t i = 0; i < q; i++) {
    double x, y;
    cin >> x >> y;
    point_t p2 = point_t({x, y});
    point_t reflect = p.reflect(p1, p2);
    reflect.print();
  }
  return 0;
}

Measured memory_bytes: 3292
#include <bits/stdc++.h>
using namespace std;
const int N = 200 * 1000 + 10;
int n, q;
string s;
pair<char, int> rd[N];
bool isvalR(int plc) {
	for (int i = 0; i < q; i++) {
		if (rd[i].first == s[plc])
			plc += rd[i].second;
		if (plc >= n)
			return true;
		if (plc < 0)
			return false;
	}
	return false;
}
bool isvalL(int plc) {
	for (int i = 0; i < q; i++) {
		if (rd[i].first == s[plc]) 
			plc += rd[i].second;
		if (plc < 0)
			return true;
		if (plc >= n)
			return false;
	}
	return false;
}
int getBSL() {
	int up = n, dw = -1;
//	cout << "L = " << endl;
	while (up - dw > 1) {
		int md = (up + dw) / 2;
//		cout << "md = " << md << endl;
		if (isvalL(md)) {
			dw = md;
		}
		else {
			up = md;
		}
	}
	return dw;
}
int getBSR() {
	int up = n, dw = -1;	
//	cout << "r = " << endl;
	while (up - dw > 1) {
		int md = (up + dw) / 2;
//		cout << "md = " << md << endl;
		if (isvalR(md)) {
			up = md;
		}
		else {
			dw = md;
		}
	}
	return up;
}
int main() {;
	cin >> n >> q;
	cin >> s;
	for (int i = 0; i < q; i++) {
		char x, y;
		cin >> x >> y;
		if (y == 'L') {
			rd[i] = {x, -1};
		}
		if (y == 'R') {
			rd[i] = {x, 1};
		}
	}
//	cout << isvalR(6) << endl;
	int l = getBSL();
	int r = getBSR();
	cout << n - (l + 1 + (n - r)); 
	return 0;
}


Measured memory_bytes: 2180
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A,B,max,min;
  cin >>N >> A>> B;
  if(A<B)max=A;
  else max=B;
  if(N>=A+B)min=0;
  else min=A+B-N;
  cout <<max <<" "<<min;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 31
#define TOP 0
#define FRONT 1
#define LEFT 2
#define RIGHT 3
#define BACK 4
#define BOTTOM 5
using namespace std;
int w,h;
string mp[N];
 
void rotN(vector<char> &dice){
  swap(dice[TOP],dice[FRONT]);
  swap(dice[FRONT],dice[BOTTOM]);
  swap(dice[BOTTOM],dice[BACK]);  
   
}
 
void rotS(vector<char> &dice){rotN(dice),rotN(dice),rotN(dice);}
 
void rotE(vector<char> &dice){
  swap(dice[TOP],dice[LEFT]);
  swap(dice[LEFT],dice[BOTTOM]);
  swap(dice[BOTTOM],dice[RIGHT]);
}
 
void rotW(vector<char> &dice){rotE(dice),rotE(dice),rotE(dice);}
 
void rotCW(vector<char> &dice){
  swap(dice[FRONT],dice[RIGHT]);
  swap(dice[RIGHT],dice[BACK]);
  swap(dice[BACK],dice[LEFT]);
}
 
typedef pair<int,int> P;
typedef pair<vector<char>,P> PP;
 
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
string ord;
 
P getStart(char ch){
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      if(mp[i][j]==ch){
    mp[i][j]='w';
    return P(j,i);
      }
}
 
int C[1<<8];
 
int bfs(int sx,int sy,int gx,int gy,vector<char> dice,int dep){
  char gch = ord[dep];
   
  int D[10][10][31][31];
  memset(D,-1,sizeof(D));
   
  D[C[dice[TOP]]][C[dice[FRONT]]][sx][sy] = 0;
  queue<PP> Q;
  Q.push(PP(dice,P(sx,sy)));
   
  int res = 1e9;
  while(!Q.empty()){
    PP t = Q.front();Q.pop();
    dice = t.first;
    int x = t.second.first;
    int y = t.second.second;
    int cost = D[C[dice[TOP]]][C[dice[FRONT]]][x][y];
         
    if(x==gx&&y==gy){
      if(dice[TOP]!=gch)continue;
      if(dep+1==(int)ord.size()) return cost;
      P st = getStart(ord[dep+1]);
      mp[gy][gx] = 'k';
      res =min(res,cost+bfs(gx,gy,st.first,st.second,dice,dep+1));
      mp[st.second][st.first] = ord[dep+1];
      mp[gy][gx] = 'w';
      continue;
    }
     
    for(int i=0;i<4;i++){
      int nx = x+dx[i];
      int ny = y+dy[i];
      vector<char> ndice = dice;
      if(i==0)rotS(ndice);
      if(i==1)rotN(ndice);
      if(i==2)rotE(ndice);
      if(i==3)rotW(ndice);
      PP sta = PP(ndice,P(nx,ny));
      if(nx<0||ny<0||nx>=w||ny>=h||mp[ny][nx]!='w')continue;
      if(D[C[ndice[TOP]]][C[ndice[FRONT]]][nx][ny]!=-1) continue;
      Q.push(sta);
      D[C[ndice[TOP]]][C[ndice[FRONT]]][nx][ny]=cost+1;
    }
  }
  return res;
}
 
int main(){
  while(1){
    cin>>w>>h;
    if(!w&&!h)break;
    for(int i=0;i<h;i++)cin>>mp[i];
    cin>>ord;
    vector<char> dice(6);
    dice[TOP]   ='r';
    dice[BOTTOM]='c';
    dice[BACK]  ='g';
    dice[FRONT] ='m';
    dice[RIGHT] ='b';
    dice[LEFT]  ='y';
    C['r'] = 0;
    C['c'] = 1;
    C['g'] = 2;
    C['m'] = 3;
    C['b'] = 4;
    C['y'] = 5;
     
    P s = getStart('#');
    P g = getStart(ord[0]);
    int ans = bfs(s.first,s.second,g.first,g.second,dice,0);
     
    if(ans<1e9) cout<<ans<<endl;
    else cout<<"unreachable"<<endl;
  }
  return 0;
}

Measured memory_bytes: 5488
H, W = gets.split.map(&:to_i)
a = []
H.times do |i|
  a << gets.split.map { |c| c.to_i.even? }
end

routes = []
H.times do |h|
  w_vec = h.odd? ? :left : :right
  w_range = (0...W).to_a
  w_range.reverse! if h.odd?
  w_range.each do |w|
    next if a[h][w]

    if h < H - 1 && (w == W - 1 && w_vec == :right || w == 0 && w_vec == :left)
      routes << [h, w, h + 1, w]
      a[h+1][w] = !a[h+1][w]
    elsif w_vec == :right && w < W - 1
      routes << [h, w, h, w + 1]
      a[h][w+1] = !a[h][w+1]
    elsif w_vec == :left && w > 0
      routes << [h, w, h, w - 1]
      a[h][w-1] = !a[h][w-1]
    end
  end
end

puts routes.size
routes.each do |route|
  puts route.map(&:next).join(' ')
end

Measured memory_bytes: 28156
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL -1
using namespace std;
const int64_t MOD = 1e9 + 7;

int main() {
	int64_t N, M;
	cin >> N >> M;

	int64_t ans = -1;
	if (2 * N == M) {
		ans = N;
	}
	else if (2 * N > M) {
		ans = M / 2;
	}
	else {
		int64_t m = M - 2 * N;
		ans = N + m / 4;
	}

	cout << ans << endl;
}

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

using namespace std;
using ll = long long;

ll n, k;

bool check(vector<ll> l, ll mid) {
    ll cut = 0;
    for (int i = 0; i < n; i++) {
        if (mid < l[i]) {
            cut += (l[i] + mid-1) / mid - 1;
        }
    }
    return cut <= k;
}

int main() {
    cin >> n >> k;
    vector<ll> l(n);
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }

    ll ok = 1e+10;
    ll ng = 0;
    while (ok - ng > 1) {
        ll mid = (ok + ng) /2;
        if (check(l, mid)) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
}

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

int main(){
  int N,K;
  cin>>N>>K;
  vector<int> S[N];
  for(int i=0;i<N;i++){
    int t,d;
    cin>>t>>d;
    S[t-1].push_back(d);
  }

  vector<int> U;
  for(int i=0;i<N;i++){
    if(S[i].empty()) continue;
    auto itr_mx = max_element(S[i].begin(),S[i].end());
    U.push_back(*itr_mx);
    S[i].erase(itr_mx);
  }
  sort(U.begin(),U.end(),greater<int>());
  vector<ll> US(U.size());
  US[0] = U[0];
  for(int i=1;i<U.size();i++)
    US[i] = US[i-1] + U[i];

  vector<int> H;
  for(int i=0;i<N;i++){
    if(S[i].empty()) continue;
    copy(S[i].begin(),S[i].end(),back_inserter(H));
  }

  if(H.empty()){
    ll ans = US[K-1] + pow(K,2);
    cout<<ans<<endl;
    return 0;
  }

  sort(H.begin(),H.end(),greater<int>());
  vector<ll> HS(H.size());
  HS[0] = H[0];
  for(int i=1;i<H.size();i++)
    HS[i] = HS[i-1] + H[i];

  ll ans = 0;
  for(int i=max(0,(int)(K-HS.size()-1));i<US.size();i++){
    if(i == K) break;
    ll man = US[i] + pow((i+1),2);
    if(i != K-1){
      int index_h = K-i-2;
      man += HS[index_h];
    }
    ans = max(ans,man);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 7032
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int MAX_N = 1000;
const int MAX_W = 1000;
int W, N;
int v[MAX_N];
int w[MAX_N];
int dp[MAX_W + 1];

void solve() {
	fill(dp, dp + W + 1, 0);
	for (int i = 0; i < N; i++) {
		for (int j = W; j >= 0; j--) {
			if (j + w[i] <= W) {
				dp[j + w[i]] = max(dp[j + w[i]], dp[j] + v[i]);
			}
		}
	}
	printf("%d\n", dp[W]);
	for (int i = W; i >= 0; i--) {
		if (dp[W] != dp[i]) {
			printf("%d\n", i + 1);
			break;
		}
	}
}

int main () {
	int i = 0;
	while (scanf("%d", &W), W) {
		i++; printf("Case %d:\n", i);
		scanf("%d", &N);
		for (int i = 0; i < N; i++) {
			scanf("%d,%d", &v[i], &w[i]);
		}
		solve();
	}
	return 0;
}

Measured memory_bytes: 1040
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int r, c;
		int i, j;
		int[][] sheet = new int[101][101];
		
		for(i = 0; i < 101; i++){
			for(j = 0; j < 101; j++){
				sheet[i][j] = 0;
			}
		}
		
		r = sc.nextInt();
		c = sc.nextInt();
		
		for(i = 0; i < r; i++){
			for(j = 0; j < c; j++){
				sheet[i][j] = sc.nextInt();
			}
		}
		
		for(i = 0; i < r; i++){
			for(j = 0; j < c; j++){
				sheet[i][c] += sheet[i][j];
			}
		}
		
		for(j = 0; j <= c; j++){
			for(i = 0; i < r; i++){
				sheet[r][j] += sheet[i][j];
			}
		}
		
		for(i = 0; i <= r; i++){
			for(j = 0; j <= c; j++){
				System.out.print(sheet[i][j]);
				
				if(j < c){
					System.out.print(" ");
				}
			}
			
			System.out.println("");
		}
	}
}

Measured memory_bytes: 41980
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int a[SIZE],dp[SIZE];
VI res;
int main(){
    int N,K; R(N,K);
    priority_queue<pair<PII,int>,vector<pair<PII,int>>,greater<pair<PII,int>>>AA;
    FOR(i,1,N){
        R(a[i]);
        AA.push({{0,-a[i]},i});
    }
    while(!AA.empty()){
        int id=AA.top().S;
        AA.pop();
        if(!a[id])continue;
        res.PB(id);
        int mi=1e9;
        FOR(i,1,N){
            if(i!=id)mi=min(mi,dp[i]);
        }
        dp[id]=mi+1;
        a[id]--;
        AA.push({{dp[id],-a[id]},id});
    }
    if(*min_element(dp+1,dp+N+1)<=K)W(-1);
    else{
        W(SZ(res));
        W(res);
    }
    return 0;
}


Measured memory_bytes: 2304
n = int(input())
s = input()
mod = 10**9 + 7

ans = 0
cnt = [1] * 26
for i,ch in enumerate(s):
    tmp = 1
    for j in range(26):
        if(j==(ord(ch) - 97)):
            continue
        tmp *= cnt[j]
        tmp %= mod
    ans += tmp
    ans %= mod
    cnt[ord(ch) - 97] += 1

print(ans)

Measured memory_bytes: 42604
a = input()

a = list(a)

b = a.pop(-1)

b = int(b)

if b == 2 or b == 4 or b == 5 or b == 7 or b == 9:
	print("hon")

if b ==0 or b==6 or b == 8 or b == 1:
	print("pon")

if b == 3:
	print("bon")

Measured memory_bytes: 9188
N, A, B = map(int, input().split())
H = [int(input()) for i in range(N)]
    
def f(x):
    s = sum([- (- max(0, h - x * B) // (A - B)) for h in H])
    if s <= x:
        return True
    else:
        return False
    
l = 0
r = 10 ** 9 + 7
while r - l > 1:
    m = (l + r) // 2
    if f(m):
        r = m
    else:
        l = m
    # print(r, l, m)
        
print(r)

Measured memory_bytes: 11060
a = list(map(int, input().split()))
ret123 = abs(a[1]-a[0]) + abs(a[2] - a[1])
ret132 = abs(a[2]-a[0]) + abs(a[1] - a[2])
ret213 = abs(a[0]-a[1]) + abs(a[2] - a[0])
ret231 = abs(a[2]-a[1]) + abs(a[0] - a[2])
ret312 = abs(a[0]-a[2]) + abs(a[1] - a[0])
ret321 = abs(a[1]-a[2]) + abs(a[0] - a[1])
print(min([ret123, ret132, ret213, ret231, ret321, ret312]))


Measured memory_bytes: 3064
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;
int main() {
    ll n,k;
    cin >> n >> k;
    ll ret = 0;
    for (ll i = k; i <= n + 1; i++) {
        ret += i*(n-i+1)+1;
        ret %= mod;
    }
    cout << ret;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;
    cin >> a >> b;
    print((a+b+1)/2);

}


Measured memory_bytes: 256
n = gets.chomp.to_i

require 'prime'

ans = 0
1.upto(n) do |i|
  next if i.even?

  tmp = 0
  a = Prime.prime_division(i)
  tmp = a.map{|x,y| y+1}.inject(:*)

  if tmp == 8
    ans += 1
  end
end

p ans


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  ll N; cin >> N;
  ll A, B; cin >> A >> B;

  ll a = N / (A + B) * A;
  ll b = min(A, N % (A + B));
  cout << a + b << endl;
}

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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

typedef struct edgeft{
  int a,b;
} edge;

int cmp(const void *a,const void *b){
  edge *p=(edge *)a;
  edge *q=(edge *)b;
  if(p->a!=q->b) return p->a-q->a;
  return p->b-q->b;
}

void run(void){
  int n,m;
  scanf("%d%d",&n,&m);
  edge *e=(edge *)malloc(sizeof(edge)*m);
  int i;
  for(i=0;i<m;i++){
    int a,b;
    scanf("%d%d",&a,&b);
    e[i].a=a;
    e[i].b=b;
  }
  qsort(e,m,sizeof(edge),cmp);
  int *min=(int *)malloc(sizeof(int)*m);
  min[m-1]=e[m-1].b;
  for(i=m-2;i>=0;i--) min[i]=MIN(min[i+1],e[i].b);
  i=0;
  int cnt=0;
  while(i<m){
    cnt++;
    int b=min[i];
    while(i<m && e[i].a<b) i++;
  }

  printf("%d\n",cnt);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define loop(i, a, b) for(ll i = a; i < b; i++)
#define rloop(i, e, s) for(ll i = e; i >= s; i--)
const ll mod = 1e9 + 7;
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(nullptr);

int main()
{
  //Prison
    ll n, m, a, b, l, r;
    cin >> n >> m;
    cin >> a >> b;
    l = a; r = b;
    loop(i, 1, m){
        cin >> a >> b;
        if(a >= l && b <= r){
            l = a; r = b;
        }
        else if(a > l && b >= r) l = a;
        else if(a <= l && b < r) r = b;
        if(l > r){
            cout << "0\n";
            return 0;
        }
    }
    cout << r-l+1 << endl;

} 

Measured memory_bytes: 256
// C - Multiple Gift

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	int ans = 1;

	ll A = X;
	while (1) {
		A *= 2;
		if (A > Y) break;
		ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import bisect
n = input()
aa = []
xx = [-input()]
for _ in xrange(n - 1):
    aa.append(-input())
for a in aa:
    if a >= xx[-1]:
        xx.append(a)
    else:
        i = bisect.bisect_right(xx, a)
        if i == len(xx):
          i -= 1
        xx[i] = a
print len(xx)

Measured memory_bytes: 6712
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<ll, int> p;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    vector<int> a(3);

    for(int i = 0; i < 3; i++) cin >> a[i];

    sort(a.begin(), a.end());

    if(a[0] + a[1] == a[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n,m;cin>>n>>m;
  cout<<n*(n-1)/2+m*(m-1)/2<<endl;
}


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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

int c[10][10];
int H, W, A, res;

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

    scanf("%d%d", &H, &W);
    rep(i, 10) rep(j, 10) scanf("%d", &c[i][j]);
    rep(k, 10) rep(i, 10) rep(j, 10)
        if( c[i][j] > c[i][k]+c[k][j] ) c[i][j] = c[i][k]+c[k][j];

    rep(i, H) rep(j, W){
        scanf("%d", &A);
        if(0 <= A) res += c[A][1];
    }

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

    return 0;
}

Measured memory_bytes: 256
#include <iostream>



int main(){
  	int N;
  	std::cin >> N;
  
 
  
  	int cnt = 0;
    int estimate = 1;
  	for (int i=0; i<N; i ++){
     	int a;
      	std::cin >> a;
      	if (a != estimate){
         	cnt ++; 
        }else{
         	estimate ++; 
        }   
    }
  	
    if (estimate == 1) std::cout<<-1;
    else           	std::cout<<cnt;  
  
  
  
  
 	return 0; 
}

Measured memory_bytes: 256
T = list(input())

for i in range(len(T)):
    if T[i] == "?":
        if i == len(T) - 1:
            T[i] = "D"
        else:
            if i > 0 and T[i - 1] == "P":
                T[i] = "D"
            elif T[i + 1] == "D" or T[i + 1] == "?":
                T[i] = "P"
            else:
                T[i] = "D"

print("".join(T))

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

int main(void){

    long long N, K;
    cin >> N >> K;
    vector<long long> height(N);
    for(long long i = 0; i < N; i++) cin >> height[i];

    long long cnt = 0;
    for(long long j = 0; j < N; j++) {
        if(height[j] >= K) cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int h = sc.nextInt();
                int w = sc.nextInt();
                int[][] a = new int[h][w];
                for(int i = 0 ; i < h ; i++){
                        for(int j = 0 ; j < w ; j++){
                                a[i][j] = sc.nextInt();
                        }
                }
                sc.close();
                int[][] q = new int[4][w * h];
                int yono = 0;
                for(int i = 0 ; i < w ; i++){
                        for(int j = 0 ; j < h - 1 ; j++){
                                if(a[j][i] % 2 != 0){
                                        q[0][yono] = j + 1;
                                        q[1][yono] = i + 1;
                                        q[2][yono] = j + 2;
                                        q[3][yono] = i + 1;
                                        yono++;
                                        a[j + 1][i]++;
                                }
                        }
                }
                for(int i = 0 ; i < w - 1 ; i++){
                        if(a[h - 1][i] % 2 != 0){
                                q[0][yono] = h;
                                q[1][yono] = i + 1;
                                q[2][yono] = h;
                                q[3][yono] = i + 2;
                                yono++;
                                a[h - 1][i + 1]++;
                        }
                }
                System.out.println(yono);
                for(int i = 0 ; i < yono ; i++){
                        System.out.print(q[0][i] + " " + q[1][i] + " " + q[2][i] + " " + q[3][i] + "\n");
                }
        }
}

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

int main(void){
    unsigned int n, k, ans;
    cin >> n >> k;
    ans = k;
    for (int i = 2; i <= n; i++) {
        ans *= (k - 1);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

#define MAX 100000
#define SENTINEL 2000000000

typedef struct{
  char suit;
  int value;
}Card;

Card L[MAX/2+2],R[MAX/2+2];

void merge(Card A[],int n,int left,int mid,int right){
  int i,j,k;
  int n1=mid-left;
  int n2=right-mid;

  for(i=0;i<n1;i++)L[i]=A[left+i];
  for(i=0;i<n2;i++)R[i]=A[mid+i];

  L[n1].value=R[n2].value=SENTINEL;
  i=j=0;
  for(k=left;k<right;k++){
    if(L[i].value<=R[j].value)A[k]=L[i++];
    else A[k]=R[j++];
  }
}

void mergeSort(Card A[],int n,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}

int partition(Card A[],int n,int p,int r){
  int i,j;
  Card t,x;

  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].value<=x.value){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }
  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;
  return i+1;
}

void quickSort(Card A[],int n,int p,int r){
  int q;
  if(p<r){
    q=partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}

int main(){
  int n,i,v;
  Card A[MAX],B[MAX];
  char S[10];
  int stable=1;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s %d",S,&v);
    A[i].suit=B[i].suit=S[0];
    A[i].value=B[i].value=v;
  }

  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);

  for(i=0;i<n;i++){
    if(A[i].suit!=B[i].suit)stable=0;
  }

  if(stable==1)printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++){
    printf("%c %d\n",B[i].suit,B[i].value);
  }
  return 0;
}



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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

//===


vector<Vi> node;
vector<Pii> ans;
Vi cnt;
Vi color;
int i_ans = 0;
map<Pii, bool> chk;

void dfs(int u, int par) {
	color[u] = 1;
	for (const auto& v : node[u]) {
		if (v == par) continue;
		Pii p1 = make_pair(u, v);
		Pii p2 = make_pair(v, u);
		if (color[v] == 1 && !chk[p1]) {
			ans.emplace_back(u, v);
			++cnt[u];
			chk[p1] = true;
			chk[p2] = true;
			continue;
		}
		if (color[v] == 0) {
			dfs(v, u);
		}
	}
	if (par == -1) {
		return;
	}
	if (cnt[u] % 2 == 0) {
		ans.emplace_back(par, u);
		++cnt[par];
	}
	else {
		ans.emplace_back(u, par);
		++cnt[u];
	}
}

int main() {
	int N, M;
	cin >> N >> M;
	if (M % 2 == 1) {
		cout << -1 << endl;
		return 0;
	}

	node.resize(N);
	cnt.resize(N);
	color.resize(N);

	for (int i = 0; i < M; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		node[a].push_back(b);
		node[b].push_back(a);
	}

	dfs(0, -1);

	for (const auto& a : ans) {
		cout << a.first + 1 << " " << a.second + 1 << endl;
	}
}

Measured memory_bytes: 22644
#include<stdio.h>

int nextInt();
void sort(int *a, int size);

int N, i;
int A, B, C[100000];
long long int a, b;

int main(){
	N=nextInt();
	for(i=N-1; i>=0; --i){
		A=nextInt();
		B=nextInt();
		C[i] = A + B;
		b += B;
	}
	sort(C, N);
	for(i=0; i<N; i+=2){
		a += C[i];
	}
	printf("%lld\n", a-b);
	return 0;
}

int nextInt(){
	int f=0; char c=getchar();
	while((c<'0')||('9'<c)){c=getchar();}
	while((c>='0')&&(c<='9')){f=f*10+(c-'0'); c=getchar();}
	return f;
}

char compare(int *x, int *y){
	return *x > *y;
}

void quickSort(int *left, int *right){
	if(left >= right){return;}
	int *pivot = left;
	int *l=left, *r=right;
	int t;
	while(1){
		while (compare(l, pivot)){l++;}
		while (compare(pivot, r)){r--;}
		if(l>=r){break;}
		t=*l; *l=*r; *r=t;
		if(pivot == l){
			pivot = r;
		}else if(pivot == r){
			pivot = l;
		}
		l++; r--;
	}
	quickSort(left, l-1);
	quickSort(r+1, right);
}

void sort(int *a, int size){
	quickSort(a, a+size-1);
}


Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
typedef struct{int y,x;}P;
int main(){
  int M,W,i,j,p=0,q=0,ans=0;
  P black[1000000];
  scanf("%d%d",&M,&W);
  int a[M][W];
  char A[M][W+1];
  for(i=0;i<M;i++)
    scanf("%s",A[i]);
  for(i=0;i<M;i++)
  for(j=0;j<W;j++){
    if(A[i][j]=='#'){
      black[p].y=i;
      black[p++].x=j;
      a[i][j]=0;
    }
    else a[i][j]=-1;
  }
  int dy[4]={1,0,-1,0},dx[4]={0,1,0,-1},by,bx,py,px;
  while(p<M*W){
    by=black[q].y;
    bx=black[q++].x;
    for(i=0;i<4;i++){
      py=by+dy[i];
      px=bx+dx[i];
      if(py>=0&&py<M&&px>=0&&px<W){
        if(a[py][px]==-1){
          a[py][px]=a[by][bx]+1;
          ans=a[py][px];
          black[p].y=py;
          black[p++].x=px;
        }
      }
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
#define foru(a,b,c) for(int a=b;a<=c;++a)
#define int long long
using namespace std;

int n,k,a[100100];
int h[100100];

main()
{
    cin >> n >> k;
    foru(i,1,n) cin >> h[i];
    foru(i,2,n) a[i]=INT_MAX;
    a[1]=0;
    foru(i,1,n)
    {
        foru(j,1,k)
        {
            a[i+j]=min(a[i+j],a[i]+abs(h[i]-h[i+j]));
        }
    }
    cout << a[n];
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template<class S,class T>
string to_string(pair<S,T> p){
	return "{"+to_string(p.first)+","+to_string(p.second)+"}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
	int N;
	cin>>N;
	vector<int> H(N);
	FOR(i,N)cin>>H[i];
	int ans=0,now=0;
	FORIN(i,1,N){
		if(H[i-1]>=H[i])now++;
		else now=0;
		ans=max(ans,now);
	}
	print(ans);
  return 0;
}


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

int main() {
  int n, a, b, c, d;
  cin >> n;
  a = n / 1000;
  b = (n - a * 1000) / 100;
  c = (n - n / 100 * 100) / 10;
  d = n - n / 10 * 10;
  
  if (b == c) {
    if (a == b)
      cout << "Yes" << endl;
    else if (c == d)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <queue>
#include <string.h>
#include <stdint.h>
#include <cmath>

#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);

#define ll long long
#define ld long double
#define ull unsigned long long
#define ut uint64_t

#define pb push_back
#define ins insert
#define er erase

#define fi(i, b) for (int i=0;i<b;i++)
#define fll(i, b) for (ll i=0;i<b;i++)
#define fla(i,a,b) for (ll i=a;i<b;i++)

#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vb vector<bool>
#define vst vector<string>
#define vpii vector<pii>
#define vpll vector<pll>
#define vv(n,m) vector<vector<ll> > vec( n , vector<ll> (m, 0))


#define all(v) v.begin(), v.end()
#define lb lower_bound
#define ub upper_bound
#define mxe max_element
#define mne min_element

#define srt(v) sort(all(v))
#define rsrt(v) sort(v.rbegin(), v.rend())

#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second

#define mii map<int, int>
#define mll map<ll, ll>
#define umii unordered_map<int, int>
#define umll unordered_map<ll, ll>

#define si set<int>
#define sll set<ll>
#define usi unordered_set<int>
#define usll unordered_set<ll>
#define spii set<pii>
#define spll set<pll>

#define pqi priority_queue<int>
#define pqll priority_queue<ll>

 #define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a)*1ll * (b)) / gcd(a, b)

#define nl "\n"
using namespace std;

double PI = (acos(-1));

ll md = 1000000007;
ll ma = 998244353;

ll pw(ll a, ll b)
{
    ll c = 1, m = a;
    while (b){
        if (b & 1)c = (c * m);
        m = (m * m);
        b /= 2;
    }
    return c;
}

ll pwmd(ll a, ll b){
    ll c = 1, m = a;
    while (b){
        if (b & 1)
            c = ((c * m)) % md;
        m = (m * m) % md;
        b /= 2;
    }
    return c;
}


ll modinv(ll n)
{
    return pwmd(n, md - 2);
}
ll min(ll a,ll b){
    if(a>=b)return b;
    return a;
    
//vst vect={'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'};
    
    
    
}
void solve(){
    
    long double a,b,x,h,ans;
    cin>>a>>b>>x;
    if(a * a * b / 2.0 <= x) {
        ans = atan(2 * (a * a * b - x) / (a * a * a));
    } else {
        ans = PI / 2 - atan(2 * x / (a * b * b));
    }
cout << fixed << setprecision(10) << ans * 180.0 / PI << endl;
}

// AB DEKHO JAADU...

int main(){

    fast;
    ll tests=1;
    //cin>>tests;
    while(tests--){
        solve();
    }

    return 0;
    }

// KHATAM HO GAYA:)...






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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();

		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		int min = Integer.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			int cnt = 0;
			while (a[i] % 2 == 0) {
				a[i] /= 2;
				cnt++;
			}

			min = Math.min(min, cnt);
		}

		pr.println(min);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21844
use proconio::{input, marker::Usize1};

fn main() {
    input!(n: usize, a: Usize1, b: Usize1);
    let d = if a < b { b - a } else { a - b };
    println!(
        "{}",
        [
            Some((a + b + 1) / 2),
            Some((n - 1 - a + n - 1 - b + 1) / 2),
            if d % 2 == 0 { Some(d / 2) } else { None }
        ]
        .iter()
        .copied()
        .filter_map(std::convert::identity)
        .min()
        .unwrap()
    );
}


Measured memory_bytes: 2140
#define _USE_MATH_DEFINES

#include <bits/stdc++.h> 
  
using namespace std;
  
#define $(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl '\n'
#define x first
#define y second    
#define int long long
#define double long double       
#define vec vector            
#define pb push_back
#define pii pair<int, int>
#define pdd pair<double, double> 
#define beg begin
  
#ifdef LOCAL
    #define dbg(x) cerr << #x << " = " << x << endl;
#else 
    #define dbg(x)
#endif 
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);                                       
    // freopen("output.txt", "w", stdout);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);  
    cout.setf(ios::fixed); cout.precision(9);    
    solve();   
    return 0;
} 

void solve() {
    int n, k;
    cin >> n >> k;
    vec<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(rall(a));
    for (int i = 0; i < min(k, n); ++i) {
        a[i] = 0;
    }

    int sum = accumulate(all(a), 0ll);

    cout << sum << endl;
}   

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

int cnt[2005];

signed main() {
#ifdef _DEBUG
	freopen("in", "r", stdin);
#endif
	int n, x, y; cin >> n >> x >> y;
	for (int i = 1; i < n; i++)
	for (int j = i + 1; j <= n; j++) {
		cnt[min(j - i, abs(x - i) + abs(y - j) + 1)]++;
	}
	for (int i = 1; i < n; i++) {
		cout << cnt[i] << '\n';
	}
}


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

int a[100005];
int main(){
  int n;
  cin >> n;
  for(int i = 0 ; i < n ; i++){
   		int x;
    	cin >> x;
    	a[x]++;
  }
  int ans = 0;
  for(int i = 1 ; i <= 99999  ; i++){
  		ans = max(ans , a[i-1] + a[i] + a[i + 1]);
  }
  cout << ans << endl;
 return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;

const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 97;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

template < class T > inline void fastScan(T &x){
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

// OrderedSet
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template < typename T > using ordered_set = tree < T, null_type, greater < T >, rb_tree_tag, tree_order_statistics_node_update >;

//typedef uint64_t hash_t;
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//const int HASH_COUNT = 2;
//const hash_t HASH_P = (uint32_t)-13337;
//uniform_int_distribution<hash_t> MULT_DIST(0.25 * HASH_P, 0.75 * HASH_P);
//const hash_t HASH_MULT[HASH_COUNT] = {MULT_DIST(rng), MULT_DIST(rng)};

int main(){
  int n, m;
  fastScan(n);
  fastScan(m);
  for(int i = 1; i <= m; i++){
    int x;
    fastScan(x);
    if(n >= 0){
      n -= x;
    }
  }
  if(n < 0) n = -1;
    printf("%d\n", n);
  return 0;
}


Measured memory_bytes: 3800