akhauriyash/Code-Regression huggingface dataset:
use std::io::{stdout, Write, BufWriter};

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

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input!{
        k: i32,
        n: usize,
        houses: [i32; n],
    }
    houses.sort();
    let first: i32;
    {first = *(houses.first().unwrap());}
    {houses.push(first + k);}

    println!("{}", k - houses.iter().skip(1)
             .zip(houses.iter().take(n))
             .map(|(&next, &previous)| next - previous )
             .max()
             .unwrap()
    );
}


Measured memory_bytes: 8444
n = int(input())
abc = []
for _ in range(n):
  abc.append(list(map(int, input().split())))
hap = abc[0]
for day in range(1, n):
  a = abc[day][0] + max(hap[1], hap[2])
  b = abc[day][1] + max(hap[0], hap[2])
  c = abc[day][2] + max(hap[1], hap[0])
  hap = [a,b,c]
print(max(hap))

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

int main()
{
  long long N;
  cin >> N;
  long long L[200];
  for (long long i = 0; i < N; ++i) {
	cin >> L[2*i + 0];
    cin >> L[2*i + 1];
  }
  sort(L, L + 2*N);
  long long ans = 0;
  for (long long i = 0; i < N; ++i) {
    ans += min(L[2*i + 0], L[2*i + 1]);
  }
  cout << ans;
  
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <map>

constexpr intmax_t mod = 1e9+7;

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
// constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }

namespace detail {
template <typename Tp, size_t N>
std::vector<Tp> make_vector(
    std::vector<size_t>& sizes,
    typename std::enable_if<(N == 1), const Tp&>::type x
) {
  return std::vector<Tp>(sizes[0], x);
}
template <typename Tp, size_t N>
auto make_vector(
    std::vector<size_t>& sizes,
    typename std::enable_if<(N > 1), const Tp&>::type x
) {
  size_t size = sizes[N-1];
  sizes.pop_back();
  return std::vector<decltype(make_vector<Tp, N-1>(sizes, x))>(
      size, make_vector<Tp, N-1>(sizes, x)
  );
}
}  // detail::

template <typename Tp, size_t N>
auto make_vector(const size_t(&sizes)[N], const Tp& x) {
  std::vector<size_t> s(N);
  for (size_t i = 0; i < N; ++i) s[i] = sizes[N-i-1];
  return detail::make_vector<Tp, N>(s, x);
}

int main() {
  char buf[131072];
  scanf("%s", buf);
  std::string S = buf;

  size_t n = S.length();
  auto dp = make_vector<intmax_t>({n, 13_zu}, 0_jd);

  if (S[0] == '?') {
    for (size_t i = 0; i < 10; ++i) dp[0][i] = 1;
  } else {
    size_t i = S[0] - '0';
    dp[0][i] = 1;
  }

  for (size_t i = 1; i < n; ++i) {
    if (S[i] == '?') {
      for (size_t j = 0; j < 13; ++j) {
        for (size_t k = 0; k < 10; ++k) {
          size_t m = (j*10 + k) % 13;
          (dp[i][m] += dp[i-1][j]) %= mod;
        }
      }
    } else {
      for (size_t j = 0; j < 13; ++j) {
        size_t m = (j*10 + (S[i]-'0')) % 13;
        (dp[i][m] += dp[i-1][j]) %= mod;
      }
    }
  }

  printf("%jd\n", dp[n-1][5]);
}


Measured memory_bytes: 13696
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int P = sc.nextInt();
    int Q = sc.nextInt();
    int R = sc.nextInt();
    int ans = Math.min(Math.min(P+Q,Q+R),R+P);
    System.out.println(ans);
  }
}
  

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <string.h>
#include <bitset>
#include <map>
#include <climits>
#include <set>

using namespace std;

int main()
{
    using T = unsigned long long;
    T a, b, x;
    cin >> a >> b >> x;

    auto count = b / x - a / x;
    if (a % x == 0)
    {
        ++count;
    }
    cout << count << endl;
    return 0;
}

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

int main() {
  int n, m, tmp = 0;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
  cin >> m;
  vector<int> t(m);
  rep(i, m) cin >> t[i];
  bool b = 0;
  sort(d.begin(), d.end());
  sort(t.begin(), t.end());
  rep(i, n){
    if(d[i] == t[tmp]){
      ++tmp;
      if(tmp == m){
        b = 1;
        break;
      }
    }
    else if(d[i] > t[tmp]) break;
  }
  if(b) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 1792
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=10*1000*1007;
const ll mod=998244353;

int n;

ll sil[nax];
ll odw[nax];
ll pot[nax];

ll wyn;

ll dziel(ll a, ll b)
{
	ll wyk=mod-2;
	while(wyk)
	{
		if (wyk&1)
			a=(a*b)%mod;
		b=(b*b)%mod;
		wyk>>=1;
	}
	return a;
}

ll kom(int a, int b)
{
	if (b>a || b<0)
		return 0;
	return sil[a]*odw[b]%mod*odw[a-b]%mod;
}

ll choc[nax];

int main()
{
	scanf("%d", &n);
	sil[0]=odw[0]=1;
	for (int i=1; i<=n; i++)
		sil[i]=(sil[i-1]*i)%mod;
	odw[n]=dziel(1, sil[n]);
	for (int i=n-1; i; i--)
		odw[i]=(odw[i+1]*(i+1))%mod;
	pot[0]=1;
	for (int i=1; i<=n; i++)
		pot[i]=(pot[i-1]*2)%mod;
	
	for (int i=n/2; i>=0; i--)
	{
		choc[i]=kom(n/2, i)*pot[n/2-i]%mod;
		choc[i]+=choc[i+1];
		choc[i]%=mod;
	}
	ll odj=1;
	for (int i=1; i<=n; i++)
		odj=(odj*3)%mod;
	for (int i=0; i<=n/2; i++)
	{
		ll jed=pot[i]*kom(n/2, i)%mod;
		wyn=(wyn+jed*choc[i+1]%mod)%mod;
	}
	
	//~ for (int i=(n+1)/2; i<=n; i++)
	//~ {
		//~ ll ter=sil[n]*odw[i]%mod*odw[n-i]%mod*pot[n-i]%mod;
		//~ wyn=(wyn+ter)%mod;
	//~ }
	
	debug() << odj << " " << wyn;
	printf("%lld\n", (odj-wyn*2%mod+mod)%mod);
	return 0;
}


Measured memory_bytes: 277504
def main():
    from itertools import product
    h, w, K = map(int, input().split())
    grid = [list(input()) for _ in [0]*h]
    m = 10**9
    for i in range(2**h):
        i = (("0"*h)+bin(i)[2:])[-h:]+"2"
        memo = [0]
        for j in range(h):
            if i[j] == i[j+1]:
                pass
            else:
                memo.append(j+1)
        ans = len(memo)-1
        ans2 = [0]
        memo2 = [0]*ans
        j = 0
        flag = False
        while j < w:
            if flag:
                break
            for k in range(ans):
                memo2[k] += [grid[l][j]
                             for l in range(memo[k], memo[k+1])].count("1")
                if memo2[k] > K:
                    ans2.append(j)
                    memo2 = [0]*ans
                    if ans2[-1] == ans2[-2]:
                        flag = True
                    break
            else:
                j += 1
        if flag == False:
            m = min(m, ans+(len(ans2)-2))
    print(m)


main()


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


int main(){
	int A,B,C,X,Y;cin>>A>>B>>C>>X>>Y;
	int mincost = A*X + Y*B;
	for(int i=2;i<=2*max(X,Y);i+=2){
		int cost = C*i;
		int ra = max(0,X-i/2),rb = max(0,Y-i/2);
		cost += ra*A + rb*B;
		mincost = min(mincost,cost);
	}
	cout<<mincost<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <assert.h>
#include <memory.h>
#include <queue>
using namespace std;

#define N 303

int dp[N][N][N];

char s[N];
void solve() {
  scanf(" %s",s+1);
  int n = strlen(s+1);
  int k;scanf("%d",&k);
  for(int cc = k;cc>=0;--cc) {
    for(int i=1;i<=n;++i) {
      for(int j=n;j>=i+1;--j) {
        dp[cc][i+1][j] = max(dp[cc][i+1][j], dp[cc][i][j]);
        dp[cc][i][j-1] = max(dp[cc][i][j-1],dp[cc][i][j]);
        if(s[i]==s[j]) {
          dp[cc][i+1][j-1] = max(dp[cc][i+1][j-1], dp[cc][i][j]+1);
        } else if(cc>0){
          dp[cc-1][i+1][j-1] = max(dp[cc-1][i+1][j-1], dp[cc][i][j]+1);
        }
      }
    }
  }
  int ret = 0;
  for(int i=1;i<=n;++i) {
    for(int cc=0;cc<=k;++cc) {
      ret = max(ret, dp[cc][i][i-1]*2);
      ret = max(ret, dp[cc][i+1][i]*2);
      ret = max(ret,1 + dp[cc][i][i]*2);
    }
  }
  printf("%d\n", ret);
}

int main() {
  //freopen("input.txt","r",stdin);
  solve();
  return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll N, D;

template< typename Data, typename T >
struct ReRooting {
 
  struct Node {
    int to, rev;
    Data data;
  };
 
  using F1 = function< T(T, T) >;
  using F2 = function< T(T, Data) >;
 
  vector< vector< Node > > g;
  vector< vector< T > > ldp, rdp;
  vector< int > lptr, rptr;
  const F1 f1;
  const F2 f2;
  const T ident;
 
  ReRooting(int n, const F1 &f1, const F2 &f2, const T &ident) :
      g(n), ldp(n), rdp(n), lptr(n), rptr(n), f1(f1), f2(f2), ident(ident) {}
 
  void add_edge(int u, int v, const Data &d) {
    g[u].emplace_back((Node) {v, (int) g[v].size(), d});
    g[v].emplace_back((Node) {u, (int) g[u].size() - 1, d});
  }
 
  void add_edge_bi(int u, int v, const Data &d, const Data &e) {
    g[u].emplace_back((Node) {v, (int) g[v].size(), d});
    g[v].emplace_back((Node) {u, (int) g[u].size() - 1, e});
  }
 
 
  T dfs(int idx, int par) {
 
    while(lptr[idx] != par && lptr[idx] < (int)g[idx].size()) {
      auto &e = g[idx][lptr[idx]];
      ldp[idx][lptr[idx] + 1] = f1(ldp[idx][lptr[idx]], f2(dfs(e.to, e.rev), e.data));
      ++lptr[idx];
    }
    while(rptr[idx] != par && rptr[idx] >= 0) {
      auto &e = g[idx][rptr[idx]];
      rdp[idx][rptr[idx]] = f1(rdp[idx][rptr[idx] + 1], f2(dfs(e.to, e.rev), e.data));
      --rptr[idx];
    }
    if(par < 0) return rdp[idx][0];
    return f1(ldp[idx][par], rdp[idx][par + 1]);
  }
 
  vector< T > solve() {
    for(int i = 0; i < (int)g.size(); i++) {
      ldp[i].assign(g[i].size() + 1, ident);
      rdp[i].assign(g[i].size() + 1, ident);
      lptr[i] = 0;
      rptr[i] = (int) g[i].size() - 1;
    }
    vector< T > ret;
    for(int i = 0; i < (int)g.size(); i++) {
      ret.push_back(dfs(i, -1));
    }
    return ret;
  }
};

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

    cin >> N >> D;

    ReRooting<ll, ll> RR(N, [](ll a, ll b){return (a*b)%D;}, [](ll a, ll b){return a+1;}, 1);
    REP(i, N-1){
    	ll x, y;
    	cin >> x >> y;
    	x--, y--;
    	RR.add_edge(x, y, 1);
    }
    auto res = RR.solve();
    REP(i, N) cout << res[i] << endl;
    return 0;
}

Measured memory_bytes: 34808
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

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

int main(){

int n, a[110];
	int i;

	cin >> n;
	for(i=0; i<n; i++) cin >> a[i];
	
	for(i=n-1; i>=0; i--){
		if(i != 0) cout << a[i] << " ";
		else cout << a[i] << endl;
	}

	return 0;



}

Measured memory_bytes: 3076
N,Y = map(int,input().split())
for x in range(0,N+1):
    for y in range(0,N-x+1):
        z = N-x-y
        if 10000*x + 5000*y + 1000*z == Y:
            print(x,y,z)
            exit()
print('-1 -1 -1')


Measured memory_bytes: 40684
#include <iostream>
#include <vector>
#include <array>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <bitset>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

long long mod = 1000000007;


int main (void) {

  long long H, W, K; std::cin >> H >> W >> K;

  std::vector<long long> amida;
  for(long long i=0; i<(1<<(W-1)); i++) {
    bool flag = false;
    for(long long j=0; j<W-2; j++) {
      if ( (i & (1<<j)) && (i & (1<<(j+1))) ) flag = true;
      if (flag) break;
    }
    if(flag) continue;
    amida.push_back(i);
  }

  struct CC {
    long long X;
    long long Y;
    long long Z;
  };
  std::vector<CC> C(W);
  for(long long i=0; i<W; i++) {
    for(auto& k : amida) {
      if ( i > 0   && (k & (1<<(i-1))) ) C[i].X++;
      else if ( i < W-1 && (k & (1<<i))     ) C[i].Z++;
      else C[i].Y++;
    }
  }

  std::vector<std::vector<long long>> dp(H+1);
  for(long long i=0; i<H+1; i++) dp[i].resize(W+1);

  dp[0][0] = 1;
  for(long long i=0; i<H; i++) {
    for(long long j=0; j<W; j++) {
      if ( j >= 1 ) dp[i+1][j-1] += ((C[j].X%mod) * (dp[i][j]%mod)) %mod ;
      dp[i+1][j] += ((C[j].Y%mod) * (dp[i][j]%mod))%mod;
      if ( j <= (W-2) ) dp[i+1][j+1] += ((C[j].Z%mod) * (dp[i][j]%mod))%mod;
    }
  }

  std::cout << dp[H][K-1]%mod << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main(){
    int H, W;
    cin >> H >> W;
    char s[55][55];
    for(int i = 1;i <= H;i++){
        for(int j = 1;j <= W;j++){
            cin >> s[i][j];
        }
    }
    for(int i = 1;i <= H;i++){
        for(int j = 1;j <= W;j++){
            if(s[i][j] == '#'){
                if(s[i-1][j] != '#' && s[i][j-1] != '#' && s[i+1][j] != '#' && s[i][j+1] != '#'){cout << "No";return 0;}
            }
        }
    }
    cout << "Yes";

}



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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
    cin >> n;
    int M = 0;

    for (int i = 0; i < n; i++) {
        int val; cin >> val;
        if (val < M) {
            cout << "No";
            return 0;
        }
        M = max(M, val - 1);
    }
    cout << "Yes" << "\n";

    return 0;
}

Measured memory_bytes: 256
import java.io.ByteArrayInputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	
	String INPUT = "";
	
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(new ByteArrayInputStream(INPUT.getBytes()));
		PrintWriter out = new PrintWriter(System.out);
		
		solve(sc, out);
		out.flush();
	}
	
	void solve(Scanner sc, PrintWriter out) {
		int W,H,x,y,r;
		
		W = sc.nextInt();
		H = sc.nextInt();
		x = sc.nextInt();
		y = sc.nextInt();
		r = sc.nextInt();
		if (x+r <= W && x-r >= 0 && y+r <= H && y-r >= 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
	}
}



Measured memory_bytes: 26456
s=int(input())
t=int(input())
u=int(input())
tate=0
yoko=0
sum=0
count=0
for i in range(s+t):
  if sum+(s-tate)<sum+(t-yoko):
    sum+=(t-yoko)
    tate+=1
  else:
    sum+=(s-tate)
    yoko+=1
  count+=1
  if u<=sum:
    break
print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define for0(i, n) for(int i = 0; i < (n); i++)
using namespace std;
int n, ans; string s;
int main() {
	cin >> n >> s;
	for0(i, n)for0(j, i) {
		if (i - j < ans)continue;
		if (j > 0 && s[i - 1] == s[j - 1])continue;
		int p = j, q = i;
		while (s[p] == s[q]) {
			p++; q++;
			if (p == i)break;
			if (q == n)break;
		}
		ans = max(ans, p - j);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr                                                                   \
  if (true)                                                                    \
  cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

vi E[1100];
vi C[1100];
long long N;
long long M;
typedef pair<int, int> pp;
bool E_chk[2000][2000];

vector<long long> b(11000);
vector<long long> c(11000);
vector<long long> a(11000);

void djk(int st, int go) {
  int cost[120];
  fill(cost, cost + 120, 1e8);

  cost[st] = 0;
  deque<pp> que;
  que.push_back(pp(0, st));
  vi cmd[1100];
  cmd[st].push_back(st);

  while (true) {
    sort(ALL(que));
    pp pos = que.front();
    que.pop_front();
    bool stop = false;
    if (pos.second == go) {
      stop = true;
      break;
    };
    REP(i, E[pos.second].size()) {
      int to = E[pos.second][i];
      int cc = C[pos.second][i];
      if (cost[pos.second] + cc >= cost[to])
        continue;
      cost[to] = cost[pos.second] + cc;
      que.push_back(pp(cost[to], to));
      cmd[to] = cmd[pos.second];
      cmd[to].push_back(to);
    }
    if (stop)
      break;
  }

  FOR(i, 1, cmd[go].size()) {
    E_chk[cmd[go][i - 1]][cmd[go][i]] = true;
    E_chk[cmd[go][i]][cmd[go][i - 1]] = true;
  }
}

void solve() {
  REP(i, N - 1) {
    FOR(j, i + 1, N) {
      if (i == j)
        continue;
      djk(i, j);
    }
  }

  ll ans = 0;
  REP(i, M) {
    int s = a[i];
    int e = b[i];
    if (!E_chk[s][e])
      ans++;
  }

  cout << ans << endl;
}

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

  cin >> N;
  cin >> M;

  for (int i = 0; i <= M - 1; i++) {
    cin >> a[i];
    a[i]--;
    cin >> b[i];
    b[i]--;
    cin >> c[i];

    E[a[i]].push_back(b[i]);
    C[a[i]].push_back(c[i]);

    E[b[i]].push_back(a[i]);
    C[b[i]].push_back(c[i]);
  }
  solve();
  return 0;
}


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

class Main {

    static final int SMALL = 1;
    static final int MIDDLE = 2;
    static final int LARGE = 3;

    public static void main( String[] args ) {

	final Scanner stdin = new Scanner( System.in );

	int[][] map = new int[10][10];

	while ( stdin.hasNextLine() ) {
	    String[] input = stdin.nextLine().split(",");
	    final int x = Integer.parseInt( input[0] );
	    final int y = Integer.parseInt( input[1] );
	    final int size = Integer.parseInt( input[2] );
	    switch ( size ) {
	    case SMALL:
		dropSmall( map, x, y );
		break;
	    case MIDDLE:
		dropMiddle( map, x, y );
		break;
	    case LARGE:
		dropLarge( map, x, y );
		break;
	    }
	}

	final int noOfZero = countZero( map );
	final int max = countMax( map );
	System.out.println(noOfZero);
	System.out.println(max);
	
    }

    static int countZero( int[][] map ) {
	int count = 0;
	for ( int i = 0; i < 10; i++ ) {
	    for ( int j = 0; j < 10; j++ ) {
		if ( map[i][j] == 0 ) {
		    count++;
		}
	    }
	}
	return count;
    }

    static int countMax( int[][] map ) {
	int max = 0;
	for ( int i = 0; i < 10; i++ ) {
	    for ( int j = 0; j < 10; j++ ) {
		if ( map[i][j] > max ) {
		    max = map[i][j];
		}
	    }
	}
	return max;
    }

    static boolean check( int val ) {
	return 0 <= val && val <= 9;
    }

    static void dropSmall( int[][] map, int x, int y ) {
	final int[] width = {0, 1, 0};
	final int[] yindex = {-1, 0, 1};
	
	for ( int i = 0; i < 3; i++ ) {
	    final int cy = y + yindex[i];
	    for ( int j = x - width[i]; j <= x + width[i]; j++ ) {
		if ( check( cy ) && check( j ) ) {
		    map[cy][j]++;
		}
	    }		
	}
	
    }

    static void dropMiddle( int[][] map, int x, int y ) {
	final int xs = Math.max( 0, x - 1 );
	final int xe = Math.min( 9, x + 1 );
	final int ys = Math.max( 0, y - 1 );
	final int ye = Math.min( 9, y + 1 );

	for ( int i = ys; i <= ye; i++ ) {
	    for ( int j = xs; j <= xe; j++ ) {
		map[i][j]++;
	    }
	}
    }
    
    static void dropLarge( int[][] map, int x, int y ) {
	final int[] width = {0, 1, 2, 1, 0};
	final int[] yindex = {-2, -1, 0, 1, 2};
	
	for ( int i = 0; i < 5; i++ ) {
	    final int cy = y + yindex[i];
	    for ( int j = x - width[i]; j <= x + width[i]; j++ ) {
		if ( check( cy ) && check( j ) ) {
		    map[cy][j]++;
		}
	    }		
	}
    }
    
}

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

int dp[25][50005];

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> c(m);
    rep(i,m) cin >> c[i];
    rep(i,m)rep(j,n+1) dp[i][j] = inf;
    dp[0][0] = 0;
    rep(i,m)rep(j,n+1) {
        if (j < c[i]) dp[i+1][j] = dp[i][j];
        else dp[i+1][j] = min(dp[i][j],dp[i+1][j-c[i]]+1);
    }
    cout << dp[m][n] << endl;
}


Measured memory_bytes: 7204
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
n=int(input())
print(a[n-1])

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef long long ll;
#define INF 1000000000
#define PI 3.14159265359

ll fac[301];

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

    ll x;
    cin >> x;

    for(ll i=0;i<150;i++){
        fac[i]=(-150+i)*(-150+i)*(-150+i)*(-150+i)*(-150+i);
    }
    fac[150] = 0;
    for(ll i=151;i<301;i++){
        fac[i]=(i-150)*(i-150)*(i-150)*(i-150)*(i-150);
    }

    for(ll i=0;i<301;i++){
        for(ll j=0;j<301;j++){
            if(fac[i]-fac[j] == x){
                cout << i-150 <<  " " << j-150 << endl;
                goto en;
            }
        }
    }
    en:{

    }
    /*
    for(ll i=0;i<301;i++){
        cout << fac[i] << endl;
    }
    */

}


Measured memory_bytes: 3604
#include "bits/stdc++.h"
#define ll long long
#define vl vector<ll>
#define pl pair<ll,ll>
#define mp make_pair
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) for(ll i=0;i<b;i++)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(),(v).end()
using namespace std;
ll mod=1000000007;

bool com2(pl a, pl b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
    int h,n,a,b;
    cin>>h>>n;
    vl dp(10005,1000000000000000000);
    dp[h]=0;
    rep(i,n){
        cin>>a>>b;
        for(int j=h;j;j--)
        dp[max(0,j-a)]=min(dp[max(0,j-a)],dp[j]+b);
    }
    cout<<dp[0]<<endl;
}

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

int main(){
  int n,m,a,total=0;
  cin >> n >> m;
  
  rep(i,m){
    cin >> a;
    total += a;
  }
  if(total <= n) cout << n - total << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define _GLIBCXX_DEBUG
const int INF=1e18;

signed main(){
  	int A,B,C,X,Y,ans;cin>>A>>B>>C>>X>>Y;
    if(2*C<A+B){
        ans=min(X,Y)*2*C;
        if(X>Y){
          	if(2*C>A)ans+=A*(X-Y);
          	else ans+=(X-Y)*2*C;
        }
        else{
          	if(2*C>B)ans+=B*(Y-X);
          	else ans+=(Y-X)*2*C;
        }
    }
    else{
        ans=A*X+B*Y;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
n,l=map(int,input().split())
aji=[]
for i in range(n):
    aji.append(l+i)
apple=200
for i in range(n):
    if apple>abs(aji[i]):
        apple=abs(aji[i])
        apple_i=i
print(sum(aji)-aji[apple_i])


Measured memory_bytes: 2940
#include <iostream>

using namespace std; 

typedef long long ll;

int main(){

    ll n;
    cin >> n;

    ll res = 0;

    ll temp = n;

    while (n){
        res += (n % 10);
        n /= 10;
    }

    // cout << res << endl;

    string ans = (temp % res == 0) ? "Yes" : "No";
    cout << ans << endl;

    
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

A,B = map(int,input().split())
def countBit(n, d):
    period = 2**d
    cont = 2**(d-1)
    n_period = n // period
    n_rest = n % period
    n_cont = max(0, n_rest - cont + 1)
    return n_period * cont + n_cont

bit = [0 for i in range(41)]
for i in range(41):
    bit[i] = (countBit(B, i+1) - countBit(max(0, A-1), i+1)) % 2
ans = 0
for i in range(41):
    ans += bit[i] * (2 ** i)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	sort(a.begin(), a.end());
	int ans = 0;
	rep(i, k) ans += a[i];
	cout << ans << endl;
	return 0;
}


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

class Main{
    public static void main(String[] args)throws IOException{
        int n, x, p = 0; /* p:????????????????????°*/

        /*??\???????????????????????????*/
        InputStreamReader isr =new InputStreamReader(System.in);
   		BufferedReader br =new BufferedReader(isr);
    	String buf = br.readLine();
        StringTokenizer st = new StringTokenizer(buf," ");
        n = Integer.parseInt(st.nextToken());
        x = Integer.parseInt(st.nextToken());
        
        while(true) {
        	if (n == 0 && x == 0) break;
            int i, j, k;
            
            for (i = 1;i <= n - 2;i++) {
                for (j = i + 1;j <= n - 1;j++) {
                    for (k = j + 1;k <= n;k++) {
                        if (i + j + k == x) p++;
                    }
                }
            }
            
            /*????????????????????° p?????????*/
            System.out.println(p);
            
            /* p?????????????????????*/
            p = 0;
            
            /*?¬??????\???????????????????????????*/
            buf = br.readLine();
            st = new StringTokenizer(buf," ");
            n = Integer.parseInt(st.nextToken());
            x = Integer.parseInt(st.nextToken());
        }
    }
}

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


Measured memory_bytes: 26344
#include <cstdio>

using namespace std;

int main()
{
	int n,sum = 0;
	
	for (int i = 0; i < 5; i++){
		scanf("%d", &n);
		if (n < 40) n = 40;
		sum += n;
	}
	
	printf("%d\n", sum/5);
	
	return (0);
}

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

#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++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    double x, h;
    while (cin >> x >> h, x)
    {
        double b = sqrt(h * h + x * x / 4) * x / 2;
        printf("%.7f\n", 4 * b + x * x);
    }
    return 0;
}


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

using namespace std;

const int N = 1e5 + 5;
int a[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int  i = 1; i <= n; i++)
    scanf("%d", a+i);
  int ans = 0;
  for (int j = 1; j <= n; j++)
    ans += (j == a[a[j]]);
  printf("%d\n", ans/2);
  return 0;
}

Measured memory_bytes: 640
N,M=gets.split.map(&:to_i)
d = M.times.map{gets.split.map(&:to_i)}
0.upto(999) do |num|
    next if num.to_s.size != N
    ok = true
    M.times do |i|
        ok = false if N<d[i][0]       
        ok = false if num.to_s[d[i][0]-1]!=d[i][1].to_s
    end
    if ok
        puts num
        exit
    end
end
puts -1

Measured memory_bytes: 1788
#include <stdio.h>
#include <string.h>

int main()
{
    int slenTP,slenP;
    char T[1000001],P[10001];
    scanf("%s",T);
    scanf("%s",P);
    slenP = strlen(P);
    slenTP = strlen(T)-strlen(P)+1;
    for(int i=0;i<=slenTP;i++)
    {
        if(strncmp(T+i,P,slenP)==0) printf("%d\n",i);
    }
}


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

class st{
public:
  string a;
  int u,d;
  bool operator<(const st & b)const{
    if (u*b.d != b.u*d)
      return u*b.d > b.u*d;
    return a < b.a;
  }
};

main(){
  int n;
  st in[50];
  while(cin>>n && n){
    rep(i,n){
      int p,a,b,c,d,e,f,m,s;
      cin>>in[i].a>>p>>a>>b>>c>>d>>e>>f>>s>>m;
      in[i].u=f*s*m-p;
      in[i].d=a+b+c+(d+e)*m;
    }
    sort(in,in+n);
    rep(i,n)cout << in[i].a << endl;
    cout <<"#"<<endl;
  }
  return false;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
struct edge { int to, cost; };
int par[114514], rrank[114514];//親、木の深さ
void init(int n) {
	rep(i, n) {
		par[i] = i;
		rrank[i] = 0;
	}
}
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rrank[x] < rrank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rrank[x] == rrank[y])rrank[x]++;
	}
}
bool same(int x, int y) {
	return find(x) == find(y);
}
signed main() {
	int x;
	cin >> x;
	for (int i = 1; i <= 50000; i++) {
		if (i * 108 / 100 == x) {
			cout << i << endl;
			ggr
		}
	}
	no();
	ggr
}



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

const int N = 1e5 + 5;


long long xor_sum(long long a) {
    //xor sum: 0^1^2^...^a
    if (a % 4 == 0) return a;
    if (a % 4 == 1) return 1;
    if (a % 4 == 2) return a + 1;
    return 0;
}


int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    long long a,b;
    cin>>a>>b;
    
    cout<<(xor_sum(a-1)^xor_sum(b))<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(){
	string S;
	vector<int> v(4);
	cin >> S;
	v[0]=10*(S[0]-'0');
	v[1]=S[1]-'0';
	v[2]=10*(S[2]-'0');
	v[3]=S[3]-'0';
	int y1=0, y2=0;
	if(v[0]+v[1]==0 || v[0]+v[1]>12){
		y1++;
	}	
	if(v[2]+v[3]==0 || v[2]+v[3]>12){
		y2++;
	}
	
	if(y1){
		if(y2){
			cout << "NA" <<endl;
		}
		else{
			cout << "YYMM" <<endl;
		}
	}
	else{
		if(y2){
			cout << "MMYY" <<endl;
		}
		else{
			cout << "AMBIGUOUS" <<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
S = input()
lst = [0 for i in S]
rl = []

for i in range(len(S)-1):
	if S[i]+S[i+1]=='RL':
		rl.append(i)

for i in rl:
	lst[i] += 1
	lst[i+1] += 1

for i in rl:
	for h in range(i,-1,-1):
		if S[h]=='L':
			a = i-(h+1)
			if a % 2 == 0:
				lst[i] += int(a / 2)
				lst[i+1] += int(a / 2)
			else:
				lst[i] += int(a / 2)
				lst[i+1] += int(a / 2)+1
			break
		if h == 0:
			a = i
			if a % 2 == 0:
				lst[i] += int(a / 2)
				lst[i+1] += int(a / 2)
			else:
				lst[i] += int(a / 2)
				lst[i+1] += int(a / 2) +1
			break

	for j in range(i+1,len(S),1):
		if S[j] == 'R':
			a = j-(i+1)-1
			if a % 2 == 0:
				lst[i] += int(a / 2)
				lst[i+1] += int(a / 2)
			else:
				lst[i] += int(a / 2)+1
				lst[i+1] += int(a / 2)
			break
		if j == len(S)-1:
			a = j - (i+1)
			if a % 2 == 0:
				lst[i] += int(a / 2)
				lst[i+1] += int(a / 2)
			else:
				lst[i] += int(a / 2)+1
				lst[i+1] += int(a / 2)
			break
			
for i in lst:
	print(i,sep = ' ',end = ' ')

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

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

int main() {
  string s;
  cin >> s;
  unordered_set<char> us;
  for (int i = 0; i < s.length(); ++i) us.insert(s[i]);

  for (char i = 'a'; i <= 'z'; ++i) {
    if (us.find(i) == us.end()) {
      cout << i << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}


Measured memory_bytes: 512
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, K = mapint()

def segfunc(x, y):
    return max(x, y)

ide_ele = 0

class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc, ide_ele):
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res

size = 10**5*3+10
seg = SegTree([0]*size, segfunc, ide_ele)
for _ in range(N):
    a = int(input())
    maxi = seg.query(max(0, a-K), min(size, a+K+1))
    seg.update(a, maxi+1)
print(seg.query(0, size))

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

bool isPalindrome(string s){
    string s_rev = s;
    reverse(s_rev.begin(), s_rev.end());
    if(s == s_rev){
        return true;
    }else{
        return false;
    }
}
int main(){
    string S;
    cin >> S;
    int l = S.size();
    int l_div = (l - 1)/2;

    if(isPalindrome(S) && isPalindrome(S.substr(0,l_div)) && isPalindrome(S.substr(l_div + 1, l_div))){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

int main(void) {
	int N, M;
	int A[10000];
	int must = 0;
	
	scanf("%d %d", &N, &M);
	for(int i = 0; i < M; i++) {
		scanf("%d", &A[i]);
		must += A[i];
	}
	
	if( N < must ) {
		printf("-1\n");
	} else {
		printf("%d\n", N - must);
	}

	return 0;
}


Measured memory_bytes: 1740
from itertools import accumulate

nim = int(input())
array = list(accumulate([int(i) for i in input().split()]))
l, r = 0, 1
ans = float("inf")
for i in range(1, nim-2):
    while abs(array[i] - 2 * array[l+1]) < abs(array[i] - 2 * array[l]) and l < i - 1: l += 1
    while abs(array[-1] - 2 * array[r+1] + array[i]) < abs(array[-1] - 2 * array[r] + array[i]) and r < nim - 2: r += 1
    t = [array[l], array[i] - array[l], array[r] - array[i], array[-1] - array[r]]
    ans = min(ans, max(t) - min(t))
print(ans)

Measured memory_bytes: 24180
s = input()
conti_cnt = 0
max_conti = 0
for i in s:
    if i in ['A', 'T', 'C', 'G']:
        conti_cnt += 1
    else:
        if max_conti < conti_cnt:
            max_conti = conti_cnt
            conti_cnt = 0
if max_conti < conti_cnt:
    max_conti = conti_cnt
print(max_conti)

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


int main(void){
    int N,x;
    cin >> N >> x;
    long long ans=0;

    vector<long long> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    if(A[0]>x){
        ans+=A[0]-x;
        A[0]=x;
    }

    for(int i=1; i<N; i++){
        if(A[i-1]+A[i]>x){
            ans+=A[i-1]+A[i]-x;
            A[i]=x-A[i-1];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  int A, B; char op;
  while (cin >> A >> op >> B){
    if (op == '?') return 0;
    if (op == '+') cout << A + B << endl;
    if (op == '-') cout << A - B << endl;
    if (op == '*') cout << A * B << endl;
    if (op == '/') cout << A / B << endl;
  }

  return 0;
}



Measured memory_bytes: 3080
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n;
double r;
struct Event {
  int index;
  double y;
  double x;
  int inout;
  Event() {;}
  Event(int index, double x, double y, int inout)
    : index(index), y(y), x(x), inout(inout) {;}
  bool operator<(const Event &rhs) const {
    return y + inout * r * 1.2 < rhs.y + rhs.inout * r * 1.2;
  }
};

set<pair<double, double> > ps;
double ys[200010];
double xs[200010];
Event events[400010];

int main() {
  while (scanf("%d %lf", &n, &r) > 0) {
    int ans = 0;
    ps.clear();
    ps.insert(make_pair(1e+100, 1e+100));
    ps.insert(make_pair(1e+101, 1e+101));
    ps.insert(make_pair(1e+102, 1e+102));
    ps.insert(make_pair(1e+103, 1e+103));
    REP(i, n) {
      int v = scanf("%lf %lf", &xs[i], &ys[i]);
      assert(v == 2);
      events[i * 2 + 0] = Event(i, xs[i], ys[i], 0);
      events[i * 2 + 1] = Event(i, xs[i], ys[i], 1);
    }
    sort(events, events + 2 * n);
    REP(i, 2 * n) {
      Event &e = events[i];
      if (e.inout == 1) {
        if (ps.count(make_pair(e.x, e.y))) { ps.erase(make_pair(e.x, e.y)); }
      } else {
        set<pair<double, double> >::iterator it = ps.lower_bound(make_pair(e.x - r * 1.2, -1e+10));
        if (hypot(e.x - it->first, e.y - it->second) <= r * 1.5) { continue; }
        it++;
        if (hypot(e.x - it->first, e.y - it->second) <= r * 1.5) { continue; }
        ps.insert(make_pair(e.x, e.y));
        ans++;
      }
    }
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 24764
// C++ Program to find best buying and selling days 
#include <bits/stdc++.h> 
using namespace std; 
#define int long long
// This function finds the buy sell 
// schedule for maximum profit 
void stockBuySell(vector<int> price, int n) 
{ 
	// Prices must be given for at least two days 
	if (n == 1) 
		return; 

	// Traverse through given price array 
	int i = 0, cur = 1000; 
	while (i < n - 1) { 

		// Find Local Minima 
		// Note that the limit is (n-2) as we are 
		// comparing present element to the next element 
		while ((i < n - 1) && (price[i + 1] <= price[i])) 
			i++; 

		// If we reached the end, break 
		// as no further solution possible 
		if (i == n - 1) 
			break; 

		// Store the index of minima 
		int buy = i++; 

		// Find Local Maxima 
		// Note that the limit is (n-1) as we are 
		// comparing to previous element 
		while ((i < n) && (price[i] >= price[i - 1])) 
			i++; 

		// Store the index of maxima 
		int sell = i - 1; 
		int bu = cur / price[buy];
	
		cur = cur - bu * price[buy] + bu * price[sell];
		
	} 
	cout << cur << '\n';
} 

// Driver code 
int32_t main() 
{ 
	int n;
	cin >> n;
	vector<int> price(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> price[i];
	}
	stockBuySell(price, n); 

	return 0; 
} 

// This is code is contributed by rathbhupendra 


Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#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 repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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, A;
  cin >> N >> A;
  vector<ll> x(N);
  rep(i, N) {
    cin >> x[i];
  }

  vector<vector<vector<ll>>> dp(
      N + 1, vector<vector<ll>>(N + 1, vector<ll>(N * 50 + 100)));

  // ll dp[N + 1][N + 1][N * 50 + 100];
  // rep(i, N + 1) {
  //   rep(j, N + 1) {
  //     rep(k, N * 50 + 100) {
  //       dp[i][j][k] = 0;
  //     }
  //   }
  // }
  dp[0][0][0] = 1;

  rep(i, N) {
    rep(j, N + 1) {
      rep(k, N * 50 + 1) {
        if (j < N && k + x[i] <= N * 50)
          dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
        dp[i + 1][j][k] += dp[i][j][k];
      }
    }
  }

  ll ans = 0;
  repp(j, 1, N) {
    ans += dp[N][j][j * A];
  }

  cout << ans << endl;
}

Measured memory_bytes: 54272
n = int(input())
e = [0] * (n + 1)
for i in range(2, n + 1):
  cur = i
  for j in range(2, i + 1):
    while (cur % j == 0):
      e[j] += 1
      cur //= j
def num(m):
  return len(list(filter(lambda x: x >= m - 1, e)))
print(num(75) + num(25) * (num(3) - 1) + num(15) * (num(5) - 1) + num(5) * (num(5) - 1) * (num(3) - 2) // 2)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define all(v)   v.begin(), v.end()
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define START cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define isOdd(n)    (n&1)
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMN INT_MIN
#define IMX INT_MAX
#define pow(n, m) power((ll)n, (ll)m)
#define numOfDigits(n)  ((n)? (ll)(log10(n))+1 : 1)
#define mem(x, val)    memset(x, val, sizeof(x)) //be careful
#define var auto
#define MOD 1000000007


typedef long long ll;
typedef long double ld;
typedef double dd;
typedef pair<int, int> pii;


ll modPow(ll x, ll n, ll m) {
    x %= m;
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * x % m;
        x = x * x % m;
        n >>= 1;
    }
    return res;
}
int main()
{
    START
    //freopen("test cases\\in.txt", "r", stdin) ;
    ll n; cin>>n;
    int arr[n], mp[n]={};
    for(int i = 0; i<n; i++)cin>>arr[i], mp[arr[i]]++;
    if(isOdd(n) && mp[0]!=1) return cout<<0, 0;
    if(!isOdd(n) && mp[0]!=0) return cout<<0, 0;
    for(int i=0; i<n; i++)
        if(arr[i] && mp[arr[i]]!=2)
            return cout<<0, 0;
    ll m = n/2;
    cout<<modPow(2, m, MOD);
	return 0;
}


Measured memory_bytes: 1024