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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    string n; cin >> n;

    if ((n[0] == n[1] && n[1] == n[2]) || (n[1] == n[2] && n[2] == n[3])) {
        puts("Yes");
    } else {
        puts("No");
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
using v = vector<int>;
ll gcd (ll a, ll b){
    return b == 0 ? a : gcd (b,a%b);
}


int main(){
    ll n;
    cin >> n;
    auto a = vector<int>(n+1,0);
    for(int i=0;i<=n;i++){
        cin >> a[i];
    }
    
    auto l = vector<int>(n+1,0);
    auto r = vector<int>(n+1,0);
    for(int i=0;i<n;i++){
        l[i+1] = gcd(a[i],l[i]);
        r[n-1-i] = gcd(a[n-1-i],r[n-i]);
    }
    auto s = vector<int>(n,0);
    for(int i=0;i<n;i++){
        s[i] = gcd(l[i],r[i+1]);
    }
    
    cout << *max_element(s.begin(),s.end());
    
    
    return 0;
}

Measured memory_bytes: 1792
#include <cstdio> 
#include <vector> 
#include <algorithm> 
using namespace std; typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int N,M; int P[100000],Y[100000]; vector <int> yd[100001];
int main() { scanf("%d%d",&N,&M); rep(i,M)scanf("%d%d",&P[i],&Y[i]),yd[P[i]].push_back(Y[i]); rep(i,N)sort(yd[i+1].begin(),yd[i+1].end()); rep(i,M)printf("%012lld\n",ll(P[i])*1000000+int(lower_bound(yd[P[i]]. begin(),yd[P[i]].end(),Y[i])-yd[P[i]].begin())+1); }


Measured memory_bytes: 7808
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        StringBuilder ab = new StringBuilder();
        StringBuilder bb = new StringBuilder();

        for (int i = 0; i < b; i++) {
            ab.append(a);
        }
        for (int i = 0; i < a; i++) {
            bb.append(b);
        }
        String as = ab.toString();
        String bs = bb.toString();

        if (as.compareTo(bs) <= 0) {
            System.out.println(as);
        }
        else {
            System.out.println(bs);
        }
    }
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define rbg rbegin()
#define red rend()
#define all(x) x.bg,x.ed
#define rall(x) x.rbg,x.red
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b; return true;} return false;}
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> t MAX(t a,u b){if(a>=b) return a; return b;}
template<class t,class u> t MIN(t a,u b){if(a<=b) return a; return b;}
template<class t> int SIZE(t s){return (int)s.size();}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using vvi=vc<vc<int>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int a,b; cin >> a >> b;
    if((a+b) % 2 != 0) cout << "IMPOSSIBLE" << endl;
    else {
        cout << (a+b) /2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long pow_mod(long long a, long long b) {
    if (b == 0) return 1;
    long long k = pow_mod(a, b/2);
    k = (k * k) % mod;
    if (b % 2 == 0) return k;
    return (k * a) % mod;
}
long long nCr(long long n, long long r) {
    long long X = 1, Y = 1;
    for (int i = 0; i < r; i++) {
        X *= (n-i);
        Y *= (i+1);
        X %= mod;
        Y %= mod;
    }
    return (X * pow_mod(Y, mod-2)) % mod;
}
int main () {
    int x = 0, y = 0;
    int X, Y;
    cin >> X >> Y;
    int a = 0, b = 0;
    while (x < X && y < Y) {
        if ((X-x) > (Y-y)) {
            x += 2;
            y += 1;
            a++;
        }
        else {
            x += 1;
            y += 2;
            b++;
        }
    }
    if (x == X && y == Y) {
        cout << nCr(a+b, a) << endl;
    }
    else {
        puts("0");
    }
}

Measured memory_bytes: 256
// warm heart, wagging tail,and a smile just for you!
//
//                            ▒█████▒▒
//                             ██████████▒
//                             ▒████████████▒
//                            ██████████████████
//                           ████████████████████▒
//                          ▒██████████████████████▒
//                          ▒███████████████████████
//                      ▒████▒▒▒▒▒▒█████████████████▒
//                    ███▒▒▒▒▒▒██████████████████████▒▒▒
//                  ▒██▒▒███████████████████████▒▒▒▒▒██████
//                 ▒█████████████████████████▒▒▒▒▒▒█████████▒
//                 ▒█████████████████████▒▒▒▒▒▒██████████████
//                  ▒████         ████▒▒▒▒▒████         ████▒
//              ▒█████▒    ████    ▒▒▒▒███████    ████    ██████▒
//            ▒██▒▒▒▒▒    ██████    █████████    ██████    ██▒▒▒██▒
//           █████████   ████████   █████████   ████████   ▒▒▒▒█████
//          ▒█████████    ██████    ████████▒    ██████    █████████
//          ▒██████████    ████    █████▒▒▒▒▒▒    ████    ██████████
//           ████████████        ▒▒▒▒▒▒▒████████        ███████████▒
//       ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒
//     ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒
//   ▒▒▒▒▒▒▒▒▒██████████████                         ███████▒▒▒▒███████████
//   █████████████████████████                     ███████▒▒▒██████████████▒
//   █████████████████████████████             ███████▒▒▒██████████████████▒
//   ██████████████████████████████████████████████████████████████████████
//    ██████████████████████████████████████████████████████████████████▒
//      ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int a,b;
  cin >> a >> b;

  if(a == 1) a+=13;
  if(b==1) b += 13;

  if(a> b) cout << "Alice" << endl;
  else if(a < b) cout << "Bob" << endl;
  else cout << "Draw" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstdio>
using namespace std;

int N, M;

vector< vector<double> > calc(vector<int> &vec) {
    vector<double> p(M+1);
    p[0] = 1.0;
    for(int i=0; i<M; i++) {
        for(int j=M; j>=0; j--) {
            if(j + 1 <= M) p[j+1] += p[j] / 3.0;
            p[j] = p[j] * 2.0 / 3.0;
        }
    }
    for(int i=0; i<M; i++) {
        p[i+1] += p[i];
    }

    // first, second, third, worst
    vector< vector<double> > dp(M+1, vector<double>(4));
    for(int i=0; i<=M; i++) dp[i][0] = dp[i][3] = 1.0;

    for(int i=1; i<N; i++) {
        vector< vector<double> > swp(M+1, vector<double>(4));
        for(int j=0; j<=M; j++) {
            int val = vec[0] * j;
            int idx = (val + vec[i] - 1) / vec[i];
            double win = (idx == 0 ? 0 : p[min(idx-1, M)]);

            for(int k=0; k<3; k++) {
                swp[j][k] += dp[j][k] * win;
                if(k + 1 < 3) swp[j][k+1] += dp[j][k] * (1 - win);
            }
            swp[j][3] += dp[j][3] * (1 - win);
        }

        swap(dp, swp);
    }

    return dp;
}

int main() {
    cin >> N >> M;
    vector<int> vi(N), da(N), vo(N);
    for(int i=0; i<N; i++) {
        cin >> vi[i] >> da[i] >> vo[i];
    }

    auto dp1 = calc(vi), dp2 = calc(da), dp3 = calc(vo);

    double ans = -1e100;
    for(int A=0; A<=M; A++) {
        for(int B=0; A+B<=M; B++) {
            double sum = 0.0;
            int C = M - A - B;
            sum += (dp1[A][0] + dp1[A][1] + dp1[A][2]) * 5.0;
            sum += (dp2[B][0] + dp2[B][1] + dp2[B][2]) * 3.0;
            sum += (dp3[C][0] + dp3[C][1] + dp3[C][2]) * 2.0;
            sum -= (dp1[A][3] + dp2[B][3] + dp3[C][3]) * 1.0;
            ans = max(ans, sum);
        }
    }
    printf("%.12f\n", ans);
    return 0;
}


Measured memory_bytes: 3724
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>
#include <map>
#include<cmath>

typedef long long ll;
using namespace std;
#define mod 10007
#define rep(i,n) for(ll i=0;i<n;i++)
#define out(s) cout << s << endl



int main(){
    ll k,x;cin >> k >> x;
    ll min=x-k+1;
    ll max=x+k-1;
    for(ll i=min;i<=max;i++){
        cout << i << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
n = gets.to_s.to_i
a = gets.to_s.split.map{ |v| v.to_i }

t = a.tally
s = a.sum
q = gets.to_s.to_i

q.times do
  b,c = gets.to_s.split.map{ |v| v.to_i }
  if t.has_key?(b)
    s += t[b] * (c - b)
    if t.has_key?(c)
      t[c] += t[b]
      t.delete(b)
    else
      t[c] = t[b]
      t.delete(b)
    end
  end
  puts s
end


Measured memory_bytes: 25760
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	fmt.Printf("2018%s\n", next()[4:10])
}


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

using namespace std;

// MACROS

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

#define vi vector<int>
#define vll vector<ll>
#define vld vector<ld>
#define u_s unordered_set

#define pii pair<int,int>
#define pll pair<ll,ll>

#define FOR(i, n) for (ll (i) = 0; i < n; i++)
#define FORN(i, a, b) for (ll (i) = a; i < b; i++)
#define FORE(i, l) for (auto (i) : l)

#define pb push_back
#define pob pop_back
#define emp emplace

#define in(n) cin >> (n);
#define debug(n) cout << #n << ": " << n << '\n';

// FUNCTIONS

template< typename T >
inline T gcd(T a, T b) { if (b) return gcd(b, a % b); return a; }

template< typename T >
inline T ext_gcd(T a, T b, T & x, T & y) { if (a == 0) { x = 0; y = 1; return b; } T x1, y1; T g = ext_gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return g; }

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
    ll n;        
    cin >> n;
    if (n % 2 == 1) cout << 0 << '\n';
    else
    {
        ll c = 0;
        ll x = 1;
        for (ll i = 2; i <= 2; i *= 2)
        {
            ll y = 1;
            for (ll j = 5; i * j <= n; j *= 5)
            {
                c += (n / (i * j));
                y++;
            }
            x++;
        }
        cout << c << '\n';
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2e9
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  cout<<fixed<<setprecision(10);
  int N;
  int hoge;
  cin >> N;
  vector<int> order(N);
  for(int i=0; i<N; ++i){
    cin >> hoge;
    order[hoge-1] = i+1;
  }
  for(int i=0; i<N-1; ++i){
    cout << order[i] << " ";
  }
  cout << order[N-1] << endl;
}

Measured memory_bytes: 1152
import java.util.*;

class Main{
	public static void main(String[] $){
		//入力
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String s = sc.next();
		sc.close();

		//処理
		boolean f = a >= 3200;

		//出力
		System.out.println(f ? s : "red");
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll INF = 1'000'000'000'000'000'000;
namespace utils{
#define ALL(x) begin(x), end(x)
#define RALL(x) rbegin(x), rend(x)
    template<class T, class Compare> using p_queue = priority_queue<T, vector<T>, Compare>;
    template<class T> using min_queue = p_queue<T, greater<T>>;
    template<class T> using max_queue = p_queue<T, less<T>>;

    template<class T> bool up_min(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
    template<class T> bool up_max(T& X, const T& A){ if(X < A) {X = A; return true;} return false; }

    ll operator"" _64(unsigned long long x){ return ll(x); }
    ull operator"" _64u(unsigned long long x){ return ull(x); }

    template<class T>
    vector<T> make_mdvector(int n, T t){
        return vector<T>(n, t);
    }
    template<class ...Ts>
    auto make_mdvector(int n, Ts ... ts){
        return vector<decltype(make_mdvector(ts...))>(n, make_mdvector(ts...));
    }

    inline ll bit(int x){
        return 1ll << x;
    }

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

    template<class T>
    ostream& operator<<(ostream& os, const vector<T>& v){
        for (auto &&x : v) { os << x << ' '; } cout << endl; return os ;
    }
}
using namespace utils;

class solver{
    istream& is;
    ostream& os;

public:
    solver(istream& I, ostream& O) :is(I), os(O) {}
    ll N;
    void run();
};

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef XELMH
    string test_cases = "test_B.txt";
    cerr << test_cases << " -->" << endl;
    auto fs = fstream(test_cases, fstream::in);
    int loop = 0;
    while(fs) {
        loop++;
        cout << '#' << loop << "#------\n";
        solver(fs, cout).run();
    }
    if(loop <= 1) {
        cout << "===" << endl;
        while(cin) solver(cin, cout).run();
    }
#else
    solver(cin, cout).run();
#endif
    return 0;
}


void solver::run(){
    is >> N;
    if(!is) return;
    string S;
    is >> S;
    for (int i = 0; i < S.size(); ++i) {
        char a = S[i] - 'A';
        a += N;
        if(a > 'Z' - 'A') a-=26;
        os << char('A'+a);
    } // end i
    os << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;	// 998244353
using ll = long long;
using namespace std;

ll power( ll a, ll b ){
	ll res = 1;
	while( b > 0 ){
		if( b & 1 ) res = res*a % mod;
		a = a*a % mod;
		b >>= 1;
	}
	return res;
}

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

	vector<int> a(n);
	for( auto &k : a ) cin >> k;

	const int a_bound = 1000010;
	vector<int> l(a_bound, 0);
	
	int p_bound = 1;
	for( auto k : a ){
		if( k == 1 ) continue;
		int t = k;
		for( int p = 2; p*p <= k; ++p ){
			int cnt = 0;
			while( t % p == 0 ){
				t /= p;
				++cnt;
			}
			p_bound = max(p_bound, p);
			l[p] = max(l[p], cnt);
		}
		if( t != 1 ){
			p_bound = max(p_bound, t);
			l[t] = max(l[t], 1);
		}
	}
	
	ll s = 1;
	for( ll p = 2; p <= p_bound; ++p ){
		while( l[p] > 0 ){
			s *= p;
			s %= mod;
			--l[p];
		}
	}
	
	ll ans = 0;
	for( auto k : a ){
		ans += s*power(k, mod-2);
		ans %= mod;
	}

	cout << ans << endl;
}

Measured memory_bytes: 4224
//  Created by sun-yryr
//

import Foundation

prefix operator *
prefix func * <T> (a: [T]) -> (T, T) {return (a[0], a[1])}
prefix func * <T> (a: [T]) -> (T, T, T) {return (a[0], a[1], a[2])}

func readInt(separator s: Character = " ") -> [Int] {return readLine()!.split(separator: s).map(){Int($0)!}}
func readDouble(separator s: Character = " ") -> [Double] {return readLine()!.split(separator: s).map(){Double($0)!}}
func readElement(separator s: Character = " ") -> [String] {return readLine()!.split(separator: s).map(){String($0)}}

extension String {
    func at(_ i: Int) -> Character {
        precondition(0 <= i && i < self.count)
        return self[self.index(self.startIndex, offsetBy: i)]
    }
}

func main() {
    let R = Int(readLine()!)!
    print(Double.pi * Double(R) * 2.0)
}

main()


Measured memory_bytes: 13020
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		long sum = 0;
		for(int i = 1 ; i <= n ; i++) {
			if(i % 3 != 0 && i % 5 != 0) {
				sum += i;
			}
		}
		System.out.println(sum);
		scan.close();
	}

}


Measured memory_bytes: 35996
#include<bits/stdc++.h>
using namespace std;
int main(void){
   int i,n;
   std::cin >> n;
   int p[n];
   int ans=0;
   for(i=0 ;i<n;i++){
      std::cin >>p[i];
    }
   for(i=1 ;i<n-1;i++){
    if(p[i-1]<p[i]&&p[i]<=p[i+1])ans++;
    else if (p[i+1]<p[i]&&p[i]<=p[i-1])ans++;
    }
    std::cout << ans << std::endl;
    
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<bitset>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)

long long INF=1e9;
const long long mod=2019;
#define ll long long

int main(){
  int N,D;
  cin>>N>>D;
  int a=1,b=0;
  while(a<=N){
    a+=2*D;
    b++;
    a++;
  }
  cout<<b<<endl;
  return 0;
}

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

int main(void){
	
	
	int S = 0;
	cin >> S;
	int h=0, m=0, s=0;

	s = S % 60;
	S = S / 60;
	m = S % 60;
	S = S / 60;
	h = S % 60;
	cout << h << ":" << m << ":" << s << endl;
	//system("pause");
	return 0;

}

Measured memory_bytes: 1164
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
int main(){
    int n=in(),k=in(),q=in();
    vec cnt(n);
    rep(i,q){
        cnt[in()-1]++;
    }
    rep(i,n){
        if(k - q + cnt[i]>0){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
}


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

int main(){

    int K, S;
    int ans = 0;
    cin >> K >> S;
    
    for(int X = 0; X <= K; X++){
        for(int Y = 0; Y <= K; Y++){
            int Z = S - (X + Y);
            if(Z <= K && Z >= 0) ans++;
        }
    }

   cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>

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

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    cout << a[0] << b[1] << c[2] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
long long int a[100007];
int main(){
	int n;
	int s=0;
	long long int b=0;
	int i,j,k;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	for(i=0;i<n;i++){
		if(2*b<a[i])s=i;
		b+=a[i];
	}
	s=n-s;
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
//string s,p;
//vector<int>v;
//map<int,int>mp;

int main()
{
    ft
    ll t,i,j,n,m,l,r,a,b;
    cin>>a>>b>>r;
    l=r-a-b;
    a=4*a*b;
    if(a<(l*l) && l>=0)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    return 0;
}

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

#define MAX_N 500000

int cnt = 0;
int A[MAX_N+1];

void merge(int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1+1]; int R[n2+1];
  for(int i=0;i<n1;i++) {
    L[i] = A[left+i];
  }
  for(int i=0;i<n2;i++) {
    R[i] = A[mid+i];
  }
  L[n1] = R[n2] = 0x7FFFFFFF;
  int i = 0; int j = 0;
  for(int k=left;k<right;k++) {
    cnt++;
    if(L[i] <= R[j]) {
      A[k] = L[i];
      i++;
    }
    else {
      A[k] = R[j];
      j++;
    }
  }
}

void merge_sort(int left, int right) {
  if(right - left > 1) {
    int mid = (left + right) / 2;
    merge_sort(left, mid);
    merge_sort(mid, right);
    merge(left, mid, right);
  }
}

int main () {
  int n; scanf("%d",&n);
  for(int i=0;i<n;i++) {
    scanf("%d ",A+i);
  }
  merge_sort(0, n);

  for(int i=0;i<n-1;i++) {
    printf("%d ",A[i]);
  }
  printf("%d\n",A[n-1]);
  printf("%d\n",cnt);
}

Measured memory_bytes: 4936
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
    int N, K, tmp;
    cin >> N >> K;
    for (int n = 0; n < N; n++) cin >> tmp;

    int res = (N - 1) / (K -1);
    if ((N - 1) % (K - 1)) res++;

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
/*int modulo(int a,int b,int n)
{
    long long x=1,y=a; 
    while(b > 0){
        if(b%2 == 1){
            x=(x*y)%n;
        }
        y = (y*y)%n; 
        b /= 2;
    }
    return x%n;
}*/
int main()
{
	string s;
	cin>>s;
	int n=s.size();int c=0;
	for (int i = 0; i < n; ++i)
	{
		if(s[i]=='A' && s[i+1]=='C')
			{cout<<"Yes"<<endl;
			c=1;break;}
	}
	if(c==0)
		cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a[3];
	scanf("%d %d %d",&a[0],&a[1],&a[2]);
	sort(a,a+3);
	if ((a[0]==a[1]&&a[1]!=a[2])||(a[0]!=a[1]&&a[1]==a[2]))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 256
from functools import reduce
from operator import mul
l = int(input())
x = list(map(int, input().split()))
# print(x)
# result = reduce(mul, x)
result = 1
limit = 10 ** 18
for i in x:
  if result < limit or i == 0:
    result = result * i
if limit < result:
  result = -1
print(result)


Measured memory_bytes: 22872
#include<cstdio>
using namespace std;

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    char a[51][51],b[51][51];
    for (int i=1;i<=n;i++)
    {
        scanf("\n");
        for (int j=1;j<=n;j++)
        {
            scanf("%c",&a[i][j]);
        }
    }
    for (int i=1;i<=m;i++)
    {
        scanf("\n");
        for (int j=1;j<=m;j++)
        {
            scanf("%c",&b[i][j]);
        }
    }
    for (int x=1;x<=n-m+1;x++)
    {
        for (int y=1;y<=n-m+1;y++)
        {
            bool ok=true;
            for (int i=1;i<=m;i++)
            {
                for (int j=1;j<=m;j++)
                {
                    if (b[i][j]!=a[x+i-1][y+j-1])
                    {
                        ok=false;
                    }
                }
            }
            if (ok)
            {
                printf("Yes\n");
                return 0;
            }
        }
    }
    printf("No\n");
    return 0;
}


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

using namespace std;

#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(t) for(ll i =0;i<t;i++)
#define bs(a,x) binary_search(a.begin(),a.end(),x)
#define ll long long int
#define ul unsigned long int
#define ld long double
#define umpi unordered_map<int,int> 
#define umpl unordered_map<ll,ll> 
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define mod 1000000007 
#define N 10000000
#define all(a) a.begin(),a.end()
#define point pair<ll,ll>

const int inf = 1000000007;
const ll linf = 1ll * inf * inf;
const ll MAXIMUM =1000005;

inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll max(ll a, ll b){return a>b?a:b;}
inline ll min(ll a, ll b){return a<b?a:b;}

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

int main()
{
	fio;
	ll n;cin>>n;
	vector<vl> c(n,vl(3));
	f(n)
	{
		for(int j=0;j<3;j++)cin>>c[i][j];
	}	
	vector<vl> dp(n,vl(3,0));
	dp[0]=c[0];
	for(ll i=1;i<n;i++)
	{
		for(int j=0;j<3;j++)
		{
			for(int k=0;k<3;k++)
			{
				if(j!=k)
				{
					dp[i][k]=max(dp[i][k],dp[i-1][j]+c[i][k]);
				}
			}
		}
	}
	cout<<*max_element(all(dp[n-1]))<<"\n";
}

Measured memory_bytes: 11264
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a,b,c,count=0;
			a=sc.nextInt();
			b=sc.nextInt();
			c=sc.nextInt();
			for(int i=a;i<=b;i++){
				if(c%i==0) count++;
			}
			System.out.println(count);
		sc.close();
	}
}



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

isPrime(int n)
{
    int i, m;
    if (i == 2) return 1;
    m = sqrt(n);
    for (i = 3; i < m; i += 2)
        if (n % i == 0) return 1;
    return 0;
}

int main2(void)
{
    int n, max, i;
    scanf("%d", &n);
    max = sqrt(n);
    printf("%d:");
    while (n % 2 == 0) {
        printf(" 2");
        n %= 2;
    }
    for (i = 3; i <= max; i += 2) {
        if (isPrime(i)) {
            while (n % i == 0) {
                printf(" %d", i);
                n %= i;
            }
        }
    }
    printf("\n");
}
main()
{
  int i, n;
   
  scanf("%d", &n);
  printf("%d:", n);
  for (i = 2; i * i <= n; ) {
    if (n % i == 0) {
      printf(" %d", i);
      n /= i;
    } else {
      ++i;
    }
  }
  printf(" %d\n", n);
}


            



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

int main() {
  int a, b, c; cin >> a >> b >> c;
  cout << max({a+b, a-b, a*b}) << endl;
}

Measured memory_bytes: 256
N = int(input())
T=[]
for i in range(N):
	x,y=map(int,input().split())
	T.append([x,y])


ANS = 0

def dfs(d, old, x):
	global ANS
	if sum(old)==N:
		ANS += d
		return

	for i in range(N):
		if not(old[i]):
			old[i]=True
			t = ((T[x][0]-T[i][0])**2 + (T[x][1]-T[i][1])**2)**.5
			dfs(d+t, old, i)
			old[i] = False


old = [False]*N

for i in range(N):
	old[i] = True
	dfs(0,old, i)
	old[i] = False

for i in range(1,N+1):
	ANS/=i
print(ANS)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i, N) for (int i=0; i<(int)N; i++)
#define rep1(i, N) for (int i=1; i<(int)N; i++)

using namespace std;

long long int N;
int K;

int main() {
  cin >> N >> K;
  int ans = 0;
  rep(i, 100) {
    if (pow(K, i) <= N && N < pow(K, i+1)) {
      ans = i+1;
      break;
    }
  }
  cout << ans;
}


Measured memory_bytes: 384
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N,X,Y = map(int,input().split())

    cost = [0 for i in range(N)]

    for i in range(1,N):
        for j in range(i,N+1):
            temp1 = abs(j-i)
            temp2 = abs(X-i) + 1 + abs(j-Y)
            temp3 = abs(Y-i) + 1 + abs(j-X)
            temp = min(temp1,temp2,temp3)
            cost[temp] += 1

    for k in range(1,N):
        print(cost[k])



main()


Measured memory_bytes: 3444
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <string>
#include <vector>

int main(int argc, char* argv[])
{
  int H, W;
  std::cin >> H >> W;
  std::string s(W+2, '#');
  std::vector< std::string > vs(H+2, s);

  for (int i = 1; i < H+1; i++) {
    for (int j = 1; j < W+1; j++) {
      std::cin >> vs[i][j];
    }
  }

  for (int i = 0; i < H+2; i++) {
    std::cout << vs[i] << std::endl;
  }

  return 0;
}


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

template<size_t N>
struct Sieve_of_Eratosthenes{
  using i32 = int32_t;
  std::array<i32,N+1> factor;
  Sieve_of_Eratosthenes(){
    factor.fill(0);
    for(i32 p=2;p<=N;++p){
      if(factor[p])continue;
      factor[p] = p;
      for(i32 x=p+p;x<=N;x+=p){
        if(factor[x])continue;
        factor[x] = p;
      }
    }
  }
  std::vector<i32> prime_factor(i32 x){
    std::vector<i32> pf;
    while(factor[x]){
      pf.push_back(factor[x]);
      x /= factor[x];
      while(factor[x]==pf.back())x/=factor[x];
    }
    return pf;
  }
};

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

  int n;
  cin>>n;
  vector<int> a(n);
  for(auto& ai:a)cin>>ai;

  constexpr int a_max = 1e6;
  Sieve_of_Eratosthenes<a_max> ushi;

  map<int,int> mp;
  bool pairwise_coprime = true;
  for(auto const& ai:a){
    for(auto const& p:ushi.prime_factor(ai)){
      if(mp.count(p)){
        pairwise_coprime = false;
        break;
      }
      mp[p]++;
    }
  }
  
  if(pairwise_coprime){
    cout<<"pairwise coprime"<<endl;
    return 0;
  }

  bool setwise_coprime = accumulate(begin(a),end(a),0,[](auto a,auto b){return gcd(a,b);}) == 1;
  if(setwise_coprime){
    cout<<"setwise coprime"<<endl;
    return 0;
  }

  cout<<"not coprime"<<endl;


}

Measured memory_bytes: 14800
#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back

using namespace std;

const int N=1e5+5;

int n,m,x,a[N],pen,cnt;

bool ac[N];

string s;

int main()
{
    cin >> n >> m;
    for (int i=0;i<m;i++)
    {
        cin >> x >> s;
        if (s=="WA"&&ac[x]==0)a[x]++;
        else if (s=="AC")
        {
            if (ac[x]==0)cnt++;
            ac[x]=1;
        }
    }
    for (int i=1;i<=n;i++)
    {
        if (ac[i])pen+=a[i];
    }
    cout << cnt << " " << pen << endl;
}



Measured memory_bytes: 768
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL;

#include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>

const int maxn = 2e5 + 20;
int a[maxn];
bool book[maxn];
void work() {
    int n, x;
    scanf("%d%d", &n, &x);
    if (x == 1 || x == 2 * n - 1) {
        printf("No\n");
        return;
    }
    int t = 2 * n - 1;
    a[t / 2 + 1] = x;
    a[t / 2] = x - 1;
    a[t / 2 + 2] = x + 1;
    book[x] = book[x - 1] = book[x + 1] = 1;
    if (t / 2 - 1 > 0 && x + 2 <= t) {
        a[t / 2 - 1] = x + 2;
        book[x + 2] = 1;
    }
    if (t / 2 + 3 <= t && x - 2 >= 1) {
        a[t / 2 + 3] = x - 2;
        book[x - 2] = 1;
    }
    int to = 1;
    for (int i = 1; i <= t; ++i) {
        if (a[i] != 0) continue;
        while (book[to] != 0) to++;
        a[i] = to;
        book[to] = 1;
    }
    printf("Yes\n");
    for (int i = 1; i <= t; ++i) {
        printf("%d\n", a[i]);
    }
}

int main() {
#ifdef local
    freopen("data.txt","r",stdin);
#endif
    work();
    return 0;
}


Measured memory_bytes: 2560
a=[]
b=int(input())
c=[]
d=[]
i=0
n=0
nn=0
while i<b:
    for x in input():
        c.append(x)
    c.sort()
    a.append(''.join(c))
    c=[]
    i+=1
a.sort()
i=1
while i<b:
    if a[i-1]==a[i]:
        if n==0:
            n=2
        else:
            n+=1
    else:
        if n!=0:
            d.append(n)
            n=0
    i+=1
if n!=0:
    d.append(n)
for x in d:
    nn+=x*(x-1)//2
print(nn)

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

public class Main {
	private static void solve(){
	//Implement solution here.
		long a = nl();
		long b = nl();
		if(a == b) {
			System.out.println(a);
		}else {
			System.out.println(xorfrom0(a-1) ^ xorfrom0(b));
		}				
	}
	
	private static long xorfrom0(long l) {
		if(l % 2 == 0) {
			return (l + 2) / 2 % 2 ^ (l + 1);
		}else {
			return (l + 1) / 2 % 2;
		}		
	}

    //Switch input source (stdin/file)
	private static Scanner scanner = new Scanner(System.in);
	public static void main(String[] args){
        String debugDataPath = System.getenv("DD_PATH");        
        if(debugDataPath != null){
            try{
                scanner = new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath)))));
            }catch(Exception e){
                throw new RuntimeException(e);
            }
        }
        solve();
	}

    //Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(scanner.nextLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
    //Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
    //Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
    //Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
    //Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
    //Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 23764
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i,a,b) for(ll i=(a);i<(b);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1LL<<59)

signed main(){
    int n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    
    n-=1;
    bool f=false;
    for(int i=0;i<=n;i++){
        int j = n-i;
        int l = c*i-d*j;
        int r = d*i-c*j;
        
        int goal = b-a;
        if(l<=goal && goal<=r)f = true;
    }
    if(f)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
S = input()
K = int(input())

cnt = 1
ans = 0
cnt2 = 1
flag = True
for i in range(1, len(S)):
  if S[i] == S[i - 1]:
    cnt += 1
    if flag:
      cnt2 += 1
  else:
    ans += cnt // 2
    cnt = 1
    flag = False

ans += cnt // 2
ans *= K
if flag:
  ans = (cnt * K) // 2
elif S[0] == S[-1] and cnt % 2 == 1 and cnt2 % 2 == 1:
  ans += K - 1

print(ans)


Measured memory_bytes: 3064
main = do
  n <- readLn :: IO Int
  ps <- getLine >>= return . map read . words :: IO [Int]

  print $ solve ps 1

  where
    solve (p:[]) i = if p == i then 1 else 0
    solve (p1:p2:ps) i = if p1 == i then 1 + (solve (p1:ps) (i+1)) else solve (p2:ps) (i+1)


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

void swap(int *a, int *b)
{
    int x;
    x = *a;
    *a = *b;
    *b = x;
}

int main()
{
    int A,B,C;
    cin >> A >> B >> C;
    swap(&A,&B);
    swap(&A,&C);

    printf("%d %d %d",A,B,C);

    
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n,t = map(int,input().split())
dg = 10**5

ab = []
tank = -1

for i in range(n):
    a,b = map(int,input().split())
    if a >= t:
        tank = max(tank,b)
    else:
        ab.append(b*dg+a)
ab.sort()

n = len(ab)

#print(ab)

if len(ab) == 0:
    print(tank)
    exit()

dp = [[0]*(t+1) for i in range(n)]

for i in range(n):
    a,b = ab[i]%dg,ab[i]//dg
    for j in range(min(a,t+1)):
        dp[i][j] = dp[i-1][j]
    for j in range(a,t+1):
        dp[i][j] = max(dp[i-1][j],dp[i-1][j-a]+b)

if len(ab) == 1:
    a,b = ab[0]%dg,ab[0]//dg
    print(b+tank)
    exit()

res = dp[n-1][t]

if tank > 0:
    res = max(res,dp[n-1][t-1]+tank)


p = 0
q = 0
for k in range(n-1,0,-1):
    a,b = ab[k]%dg,ab[k]//dg
    q += b
    res = max(res,q+dp[k-1][t-p-1])
    p += a
    if p >= t:
        break
print(res)

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

using namespace std;
typedef long long ll;

vector<vector<ll>> G;
ll N;
ll dp[100000][2];
ll MOD = 1e9+7;

ll dfs(ll n, ll col, ll par){
    if(dp[n][col] != -1) return dp[n][col];
    if((G[n].size() == 1 && par != -1) || (G[n].size() == 0 && par == -1)){
        if(col == 0) return dp[n][col] = 2;
        else return dp[n][col] = 1;
    }
    ll ans_w = 1;
    for(auto &e : G[n]){
        if(e == par) continue;
        ans_w *= dfs(e, 0, n);
        ans_w %= MOD;
    }
    if(col == 0){
        ll ans_b = 1;
        for(auto &e : G[n]){
            if(e == par) continue;
            ans_b *= dfs(e, 1, n);
            ans_b %= MOD;
        }
        ans_w += ans_b;
    }
    return  dp[n][col] = ans_w % MOD;
}

int main(){
    cin >> N;
    G.resize(N);
    for(int i=0;i<N-1;i++){
        ll a,b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
    for(int i=0;i<100000;i++) dp[i][0] = dp[i][1] = -1;
    cout << dfs(0,0,-1) << endl;
    return 0;
}

Measured memory_bytes: 14208
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static readonly int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			//Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//int K = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			int a = vs[0];
			int b = vs[1];
			int c = vs[2];
			if (a == b && a != c) {
				Console.WriteLine("Yes");
			} else if (a == c && a != b) {
				Console.WriteLine("Yes");
			} else if (b == c && b != a) {
				Console.WriteLine("Yes");
			} else {
				Console.WriteLine("No");
			}



			//Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 13268
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int height(vint& v, int w)
{
	int res = 0, pl = 0;
	
	rep(i, v.size())
	{
		if(w < pl + v[i])
		{
			res++;
			
			if(w < v[i]) return 1 << 30;
			
			pl = 0;
		}
		
		pl += v[i];
	}
	
	return res + (pl != 0);
}

int main()
{
	int m, n;
	while(cin >> m >> n && n)
	{		
		vint v(n);
		rep(i, n) cin >> v[i];
		
		int lb = 1, ub = 1500000;
		
		while(ub - lb > 1)
		{
			int mid = (ub + lb) / 2;
			
			if(height(v, ceil(mid)) <= m) ub = mid;
			else lb = mid;
		}
		
		cout << ub << endl;
	}
}

Measured memory_bytes: 0
import java.util.*;


class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        Map<String, Integer> dic = new TreeMap<>();
        int N = sc.nextInt();
        sc.nextLine();

        Set<Integer> s = new HashSet<>();

        for (int i = 0; i < N; i++) {
            int tmp = sc.nextInt();
            if (s.contains(tmp)) {
                System.out.println("NO");
                System.exit(0);
            } else {
                s.add(tmp);
            }
        }
        System.out.println("YES");
    }
}

Measured memory_bytes: 98620
#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>;

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; }
const ll INF = 1LL << 60;

//---main---------------------------------------------
int main(){
    //main
    int a;
    cin >> a;

    cout << a+a*a+a*a*a << endl;

    return 0;
}

Measured memory_bytes: 3620
import sys
readline = sys.stdin.readline
directions = [(0, -1), (0, 1), (-1, 0), (1, 0)]

def main():
    H, W = map(int, readline().rstrip().split())
    S = [readline().rstrip() for _ in range(H)]
    res = 'Yes'
    for h in range(H):
        for w in range(W):
            if S[h][w] != '#':
                continue
            flg = False
            for dh, dw in directions:
                if 0 <= h+dh < H and 0 <= w+dw < W:
                    if S[h+dh][w+dw] == '#':
                        flg = True
                        break
            if not flg:
                res = 'No'
                break
        else:
            continue
        break

    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3192
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>
#include <climits>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))

int f(ll N) {
  int ans = 0;
  int upper=100;
  for (int x = 1; x < upper; ++x)
  {
    for (int y = 1; y < upper; ++y)
    {
      for (int z = 1; z < upper; ++z)
      {
        ll val = x * x + y * y + z * z + x * y + y * z + z * x;
        if (val == N)
          ans++;
        if (val >= N)
          break;
      }
    }
  }
  return ans;
}

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

  rep(i, N) {
    cout << f(i+1) << endl;
  }

  return 0;
}

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

int N, a[2001], dp[2][2001][2001];

int recursion_X(int y, int k)
{
	if (dp[0][y][k] >= 0) return dp[0][y][k];
	else dp[0][y][k] = abs(a[N] - a[y]);
	
	int i, tmp;
	for (i = k; i <= N - 1; i++) {
		tmp = recursion_Y(i, i + 1);
		if (tmp > dp[0][y][k]) dp[0][y][k] = tmp;
	}
	return dp[0][y][k];
}

int recursion_Y(int x, int k)
{
	if (dp[1][x][k] >= 0) return dp[1][x][k];
	else dp[1][x][k] = abs(a[N] - a[x]);
	
	int i, tmp;
	for (i = k; i <= N - 1; i++) {
		tmp = recursion_X(i, i + 1);
		if (tmp < dp[1][x][k]) dp[1][x][k] = tmp;
	}
	return dp[1][x][k];
}

int main()
{
	int i, j;
	scanf("%d %d %d", &N, &i, &(a[0]));
	for (i = 1; i <= N; i++) scanf("%d", &(a[i]));
	for (i = 0; i <= N; i++) {
		for (j = 1; j <= N; j++) {
			dp[0][i][j] = -1;
			dp[1][i][j] = -1;
		}
	}
	printf("%d\n", recursion_X(0, 1));
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 33080
using System;
using System.Collections.Generic;
namespace AOJ {
    internal class Program {
        public static void Main(string[] args) { new Program().solve(); }
        void solve() {
            var ans = new List <String>();
            while(true) {
                var s = Console.ReadLine();
                if(s == "-") break;
                var m = int.Parse(Console.ReadLine());
                for(int i = 0; i < m; ++i) {
                    var h = int.Parse(Console.ReadLine());
                    s = s.Substring(h, s.Length - h) + s.Substring(0, h);
                }
                ans.Add(s);
            }
            foreach(var a in ans) { Console.WriteLine(a); }
        }
    }
}



Measured memory_bytes: 9044
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	int a, e, k;
	cin >> a >> e >> e >> e >> e >> k;
	cout << (e - a <= k ? "Yay!" : ":(") << endl;
	return 0;
}
 

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


def convert(l):
    x, arm = l
    return [x-arm, x+arm]


L = [convert(list(map(int, input().split()))) for _ in range(n)]
L.sort(key=lambda x:x[0])
# print(L) #kesu

last = -10**9-1
count = 0
for ind, elm in enumerate(L):
    # print(last) #kesu
    if elm[0] >= last:
        last = elm[1]
        count += 1
    elif elm[1] < last:
        last = elm[1]
    else:
        pass

print(count)

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

int main(){
    int n;
    cin >> n;
    int sum=0,p;
    int ma=-1;
    for(int i=0;i<n;i++){
        cin >> p;
        if(ma<p)ma=p;
        sum+=p;
    }
    sum -= ma;
    cout << sum+ma/2 << endl;

    return 0;
}


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

typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define mp make_pair

char s[10];

int main(){
    scanf("%s", s);
    if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]){
        puts("Bad");
    } else {
        puts("Good");
    }
    return 0;
}


Measured memory_bytes: 256