akhauriyash/Code-Regression huggingface dataset:
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

constexpr usize operator"" _z(unsigned long long x) noexcept {
  return static_cast<usize>(x);
}

class rep {
  const usize f, l;

public:
  class itr {
    friend rep;
    usize i;
    constexpr itr(const usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr rep(const usize first, const usize last) noexcept
      : f(first), l(last) {}
  constexpr itr begin() const noexcept { return itr(f); }
  constexpr itr end() const noexcept { return itr(l); }
};
class revrep {
  const usize f, l;

public:
  class itr {
    friend revrep;
    usize i;
    constexpr itr(usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
  constexpr itr begin() const noexcept { return itr(l); }
  constexpr itr end() const noexcept { return itr(f); }
};
template <class T> using vec_alias = std::vector<T>;
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) {
  return a < b ? b - a : a - b;
}

} // namespace n91

#include <utility>

namespace n91 {

template <class T> constexpr T gcd(T m, T n) noexcept {
  while (n != static_cast<T>(0)) {
    m %= n;
    std::swap(m, n);
  }
  return m;
}

template <class T> constexpr T lcm(const T &m, const T &n) noexcept {
  return m / gcd(m, n) * n;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <utility>

namespace n91 {

void main_() {
  usize n, k;
  std::cin >> n >> k;

  usize cur = (n - 2_z) * (n - 1_z) / 2_z;

  if (cur < k) {
    std::cout << "-1" << std::endl;
    return;
  }

  std::cout << (n - 1_z) + (cur - k) << std::endl;

  for (const auto i : rep(1_z, n)) {
    std::cout << 0_z + 1_z << " " << i + 1_z << std::endl;
    for (const auto j : rep(1_z, i)) {
      if (cur > k) {
        std::cout << i + 1_z << " " << j + 1_z << std::endl;
        --cur;
      }
    }
  }
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n, k;
	cin >> n >> k;
	vector<double> p(n);
	vector<double> sum(n);
	rep(i, n){
		int in;
		cin >> in;
		p.at(i) = (double)(in+1)/2;
		if(i == 0) sum.at(i) = p.at(i);
		else sum.at(i) = p.at(i) + sum.at(i-1);
	}

	double ans = 0;
	rep(i, n-k+1){
		double now;
		if(i == 0) now = sum.at(i+k-1);
		else now = sum.at(i+k-1) - sum.at(i-1);
		ans = max(ans, now);
	}
	printf("%f\n", ans);
	return 0;
}

Measured memory_bytes: 3328
import math

n = int(input())
for i in range(n):
    xa, ya, ra, xb, yb, rb = map(float, input().split())

    d = math.sqrt((xa - xb)**2 + (ya - yb)**2)

    if ra > d + rb:
        print("2")
    elif rb > d + ra:
        print("-2")
    elif d > ra + rb:
        print("0")
    else:
        print("1")



Measured memory_bytes: 5664
#include<algorithm>/*{{{*/
#include<cctype>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<vector>
using namespace std;
typedef long long lld;
typedef long double lf;
typedef unsigned long long uld;
typedef pair<int,int> pii;
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define FOR(i,a,b) for(lld i=(a);i<=(b);++i)
#define ROF(i,a,b) for(lld i=(a);i>=(b);--i)
/******************heading******************/
const lld N=3e5+5,P=998244353;
lld n,a,b;
lld fac[N],fnv[N];
lld k;
lld gcd(lld a,lld b){return b?gcd(b,a%b):a;}
lld exgcd(lld a,lld b,lld &x,lld &y){
    if(!b)return x=1,y=0,a;
    lld t=exgcd(b,a%b,y,x);
    return y-=(a/b)*x,t;
}
lld inv(lld a){
    lld x,y;
    exgcd(a,P,x,y);
    return (x%P+P)%P;
}
lld binom(lld a,lld b){
    if(a<b)return 0;
    //printf("binom(%lld,%lld):%lld\n",a,b,1ll*fac[a]*fnv[b]%P*fnv[a-b]%P);
    return 1ll*fac[a]*fnv[b]%P*fnv[a-b]%P;
}

int main(){
    cin>>n>>a>>b>>k;
    //scanf("%lld%lld%lld%lld",&n,&a,&b,&k);
    lld g=gcd(a,b);
    if(k%g)return puts("0"),0;
    if(!k)return puts("1"),0;

    fac[0]=1;
    FOR(i,1,n)fac[i]=1ll*fac[i-1]*i%P;
    fnv[n]=inv(fac[n]);
    ROF(i,n,1)fnv[i-1]=1ll*fnv[i]*i%P;

    a/=g,b/=g,k/=g;
    lld x0,y0,ans=0;
    exgcd(a,b,x0,y0);
    //printf("a:%lld,b:%lld\n",a,b);
    x0*=k,y0*=k;
    //printf("x0:%lld,y0:%lld\n",x0,y0);
    lld lt=ceil(-1.0*x0/b),rt=floor(1.0*y0/a);
    //printf("l:%lld,r:%lld\n",lt,rt);
    FOR(t,lt,rt){
        lld x=x0+b*t;
        lld y=y0-a*t;
        if(x>n||y>n)continue;
        //printf("x:%lld,y:%lld\n",x,y);
        ans=(ans+1ll*binom(n,x)*binom(n,y)%P)%P;
    }
    cout<<ans<<endl;
    //printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	int n, m;
	cin >> n >> m;
	V a(m);
	rep(i, m) {
		cin >> a[i];
	}
	// greedy
	/*
	sort(all(a));
	int ans = 0;
	for (int i = m - 1; i >= 0; i--) {
		while (n - a[i] >= 0) n -= a[i], ans++;
	}
	cout << ans << endl;
	*/
	// dp
	V dp(n + 1, n + 1);
	dp[0] = 0;
	rep(i, n) rep(j, m) {
		if (i + a[j] > n) continue;
		chmin(dp[i + a[j]], dp[i] + 1);
	}
	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 3136
import math
from itertools import permutations
N = int(input())
C = [list(map(int, input().split())) for _ in range(N)]
perm = list(permutations(range(N)))
d = 0
for p in perm:
    for i in range(N - 1):
        d += math.sqrt((C[p[i]][0] - C[p[i + 1]][0]) ** 2 + (C[p[i]][1] - C[p[i + 1]][1]) ** 2)
print(d / len(perm))


Measured memory_bytes: 13988
x1, y1, x2, y2 = map(int, input().split())
dx = x2 - x1
dy = y2 - y1
x3 = x2 - dy
y3 = y2 + dx
x4 = x3 - dx
y4 = y3 - dy
print("%d %d %d %d" % (x3, y3, x4, y4))

Measured memory_bytes: 3064
n = int(input())
s = [0,0,0,0,0]
for i in range(n):
  si = input()[0]
  if si in ["M","A","R","C","H"]:
    s[["M","A","R","C","H"].index(si)] += 1
m = s[0]*s[1]*s[2]+s[0]*s[1]*s[3]+s[0]*s[1]*s[4]+s[0]*s[2]*s[3]+s[0]*s[2]*s[4]+s[0]*s[3]*s[4]+s[1]*s[2]*s[3]+s[1]*s[2]*s[4]+s[1]*s[3]*s[4]+s[2]*s[3]*s[4]
print(m)

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

typedef long long ll;


int main() {
    int N;
    ll K;
    cin >> N >> K;
    vector<ll> d(100000);
    for (int i=0;i<N;i++){
        int a, b;
        cin >> a >> b;
        a--;
        d[a] += b;
    }
    for (int i=0;i<100000;i++){
        if (K<=d[i]) {
            cout << i+1 << "\n";
            return 0;
        }
        K -= d[i];
    }
    
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
// #include <atcoder/all>
// using namespace atcoder;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vb = vector<bool>;
using vs = vector<string>;
using vvi = vector<vi>;
using vp = vector<pii>;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define each(a, x) for (auto&& a : (x))
#define _overload3(_1, _2, _3, name, ...) name
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) for (int i = (a); i < (n); ++i)
#define rep(...) _overload3(__VA_ARGS__, rep3, rep2, rep1)(__VA_ARGS__)
constexpr int inf = (1 << 30) - 1;
constexpr int mod = 1e9 + 7;
constexpr double eps = 1e-10;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
template<typename T> constexpr void print(const T& t) {cout << t << "\n";}
template<typename T, typename U> constexpr bool chmax(T& a, const U& b) {if (a < b) a = b; return a < b;}
template<typename T, typename U> constexpr bool chmin(T& a, const U& b) {if (a > b) a = b; return a > b;}
template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& p) {is >> p.fi >> p.se; return is;}
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) {os << p.fi << " " << p.se; return os;}
template<typename T> istream& operator>>(istream& is, vector<T>& v) {rep(i, sz(v)) is >> v[i]; return is;}
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {rep(i, sz(v)) os << v[i] << (i + 1 != sz(v) ? " " : ""); return os;}
struct Init {Init() {cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10);}} init;

int main() {
    int s;
    cin >> s;
    vi dp(s + 1, 0);
    dp[0] = 1;

    rep(i, s + 1) {
        rep(j, s + 1) {
            if (j <= i - 3) {
                dp[i] += dp[j];
                dp[i] %= mod;
            }
        }
    }

    print(dp[s]);
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<limits.h>
#include<string>
#include<iomanip>
#include<numeric>
#include<queue>
using namespace std;

long long  mod = 1000000007;

long max(long x, long y) {
	return x > y ? x : y;
}

long min(long x, long y) {
	return x < y ? x : y;
}

long factorial(long n) {
	if (n == 1) {
		return 1;
	}
	else {
		return n * factorial(n - 1);
	}
}

long long  fel(long long  n,long long  f) {

		if (f == 1) {
			return n % mod;
		}
		else if (f % 2 == 0) {
			return (fel(n,f / 2) * fel(n,f / 2)) % mod;
		}
		else {
			return ((n  * fel(n,f / 2) %mod) * fel(n,f / 2))% mod;
		}
	

}


int main()
{
	double n;
	cin >> n;
	vector<double> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());

	
	for (int i = 0; i < n-1; i++) {
		a[i + 1] = (a[i] + a[i + 1]) / 2;
	}
	cout << setprecision(10)<<a[n-1];
 

}



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

sames = 1
ans = 0
prev = 'prev'

# 文字列1回分の重複削除の操作回数
for s in S:
	if prev == s:
		sames+=1
	else:
		if sames > 1:
			ans+=(sames//2)
			sames = 1
	prev = s
ans+=(sames//2)

# 先頭と末尾の連続回数をカウント
add_f = 0
add_b = 0
if S[0] == S[len(S)-1]:
	for s in S:
		if s == S[0]:
			add_f+=1
		else:
			break
	for sr in reversed(S):
		if sr == S[len(S)-1]:
			add_b+=1
		else:
			break
add = add_f+add_b

# すべて同じ文字の時とそうじゃない時を場合分け
if len(set(list(S))) == 1:
	print(K*len(S)//2)
else:
	print(ans*K + (add//2)*(K-1) - (add_f//2)*(K-1) - (add_b//2)*(K-1))

Measured memory_bytes: 3064
#include <stdio.h>
#define MOD 1000000007

int main(void){
  int s;
  scanf("%d", &s);

  long a[2001] = {1};
  if(s < 3){
    puts("0");
    return 0;
  } 
  else{
    for(int i = 3;i <= s;i++){
      a[i] = a[i-1]+a[i-3];
      a[i] %= MOD;
    }
  }
  printf("%ld\n", a[s]);

  return 0;
}

Measured memory_bytes: 1752
#include <iostream>
#define TIME 100000
using namespace std;

int main(void){
  int X;
  cin >> X;
  //ここまで入力

  long long cum[TIME] = {0};
  for(int i=0; i<TIME-1; i++)
    cum[i+1] = cum[i] + (i+1);

  for(int i=0; i<TIME; i++)
    if(X <= cum[i]){
      cout << i << endl;
      return 0;
    }
  
  return 0;
}


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

using namespace std;

#define FaSt ios::sync_with_stdio(0),cin.tie(0);
#define random uniform_int_distribution<long long>(1, 2000000000000000LL)(rng)
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count() * ((uint64_t) new char | 1));

const int N = 100005;
int n, r, b, g, a[N];
long long dp[N][3];
bool solved[N][3];

long long calc(int i, int j)
{
    if (i == 0)
    {
        return 1;
    }
    
    if (solved[i][j])
    {
        return dp[i][j];
    }
    
    if (i >= r && j == 2)
    {
        dp[i][j] += calc(i - r, 2);
    }
    if (i >= g && j >= 1)
    {
        dp[i][j] += calc(i - g, 1);
    }
    if (i >= b)
    {
        dp[i][j] += calc(i - b, 0);
    }
    
    solved[i][j] = 1;
    return dp[i][j];
}

int main() 
{
    FaSt
    cin >> r >> b >> g >> n;
    cout << calc(n, 2);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
inline int read()
{int x=0;
char c=getchar();
while (c<'0'||c>'9') c=getchar();
while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
return x;
}
struct node
{int f[3];
};
int head[200005],nxt[200005],v[200005],tot=0;
int dep[200005],son[200005],sz[200005],rt[200005],fr[200005],ed[200005],n,cnt=0;
vector <node> vec[200005];
inline void add(int a,int b)
{tot++;nxt[tot]=head[a];head[a]=tot;v[tot]=b;}
inline int max(int a,int b)
{return a>b?a:b;}
void dfs(int pos)
{if (!head[pos])
{rt[pos]=++cnt;
fr[cnt]=ed[cnt]=dep[pos];
sz[cnt]=1;
return;
}
int c=0,p=0,l=0;
for (int i=head[pos];i;i=nxt[i])
{dep[v[i]]=dep[pos]+1;dfs(v[i]);
if (sz[rt[v[i]]]>c)
{c=sz[rt[v[i]]];p=rt[v[i]];l=v[i];}
}
son[pos]=l;rt[pos]=p;
fr[p]=dep[pos];sz[p]++;
}
inline node make(int a,int b,int c)
{node tp;tp.f[0]=a;tp.f[1]=b;tp.f[2]=c;return tp;}
inline void merge(int a,int b,int f)
{int fa=f-fr[a],fb=f-fr[b],i,j,g[3];
while (fb<sz[b])
{g[0]=g[1]=g[2]=0;
for (i=0;i<3;i++)
{for (j=0;j<2;j++)
{int nxt=(i+j>=2?2:i+j),p=(1ll*vec[a][fa].f[i]*vec[b][fb].f[j])%mod;
g[nxt]=(g[nxt]+p>=mod?g[nxt]+p-mod:g[nxt]+p);
}
}
for (i=0;i<3;i++) vec[a][fa].f[i]=g[i];
fa++;fb++;
}
}
void dp(int pos)
{int now=rt[pos],maxn=0;
if (son[pos]) dp(son[pos]);
for (int i=head[pos];i;i=nxt[i])
{if (v[i]==son[pos]) {continue;}
dp(v[i]);merge(now,rt[v[i]],dep[pos]+1);
maxn=max(maxn,ed[rt[v[i]]]);
}
for (int i=dep[pos]-fr[now]+1;i<=maxn-fr[now];i++)
{vec[now][i].f[0]+=vec[now][i].f[2];
if (vec[now][i].f[0]>=mod) vec[now][i].f[0]-=mod;
vec[now][i].f[2]=0;
}
vec[now][dep[pos]-fr[now]]=make((mod+1)>>1,(mod+1)>>1,0);
}
int main (){
	int i,p,tp=2;
	n=read();
	for (i=1;i<=n;i++)
	{p=read();add(p,i);tp<<=1;
	if (tp>=mod) tp-=mod;
	}
	dfs(0);
	for (i=1;i<=cnt;i++)
	{vec[i].resize(sz[i]);}
	dp(0);
	int rot=rt[0],ans=0;
	for (i=0;i<sz[rot];i++)
	{ans+=vec[rot][i].f[1];
	if (ans>=mod) ans-=mod;
	}
	printf ("%d\n",(1ll*ans*tp)%mod);
	return 0;
}

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

int main(){
  int a, b, d, e;
  int c = 13;
  int i = 0;
  int ans = -1;

  cin >> a >> b;

  while (i < 10000){
    d = c * 0.08;
    e = c * 0.1;

    if (d == a && e == b){
      ans = c;
      break;
    }

    i++;
    c++;
  }

  if (ans != -1) cout << ans << endl;
  else cout << "-1" << endl;

  return 0;
}


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

int OceanView(int N){
    int H[N]={};
    for(int i=0;i<N;i++){
        cin >> H[i];
    }
    int cnt=1;
    for(int i=1;i<N;i++){
        bool flg=false;
        for(int j=0;j<i;j++){
            if(H[j]<=H[i]){
                flg=true;
            }
            else{
                flg=false;
                break;
            }
        }
        if(flg==true){
            cnt++;
        }
    }
    return cnt;
}
int main(){
    int N; cin >> N;
    cout << OceanView(N) << endl;
    return 0;
}

Measured memory_bytes: 256
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*                                                    
      I ♥ CLARICE STARLING...                                                               
        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
const ll INF = (ll)2e18 + 77;
void solve()
{
    int n,i;cin>>n;
    int A[n][2];
    int x1,y1,x2,y2;
    ll mx,mn;
    mx=mn=INT64_MIN;
    fo(i,0,n)
    {
        cin>>A[i][0]>>A[i][1];
        if(mx<A[i][0]+A[i][1])
        {
            mx=A[i][0]+A[i][1];
            x1=A[i][0];
            y1=A[i][1];
        }
        if(mn<A[i][0]-A[i][1])
        {
            mn=A[i][0]-A[i][1];
            x2=A[i][0];
            y2=A[i][1];
        }
    }
    ll m=INT64_MIN;
    fo(i,0,n)
    {
        m=max(m,max(mx-(A[i][0]+A[i][1]),mn-(A[i][0]-A[i][1])));
    }
    cout<<m<<"\n";
}
int main()
{
   fastio
   //Test_cases
   solve();
  return 0;
}
//**always check if you are not killing input in between
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
// Syntax to create a min heap for priority queue priority_queue <int, vector<int>, greater<int>>; 
//for modinverse use modularexponention(x,M-2,M);
//for "each" subtraction from ans(ans-k) if(ans<0) do ans+=MOD,ans%=MOD
//vector<vector<int>>dp(201,vector<int>(n+1)); A way to initialize vector of vector
//string2=string1.substr(pos,length);if len no specified then till end
//void fill (ForwardIterator first, ForwardIterator last, const T& val);
//The range filled is [first,last), which contains all the elements between first and last, including the element pointed by first but not the element pointed by last.


//If wrong on pretest 2 means logically wrong
/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


Measured memory_bytes: 5196
/*********************
*  Author: xuziyuan  * 
*********************/
 
#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <LL,LL>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair
 
using namespace std;
 
const LL MOD=1e9+7;

int h,n,x,sum=0;

int main()
{
	cin>>h>>n;
	rep(i,n)
	{
		cin>>x;
		sum+=x;
	}
	if(sum>=h) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int n;
  cin >> n;
  
  vector<int> v(n);
  for(int i; i < n; i++)
    cin >> v.at(i);
  vector<int> w(n - 1);
  
  int j = 0;
  
  while(j < n - 1){
    
    int k = 0;
    int l = j + 1;
    int s = 0;
    int t = 0;
    
    while(k <= j){
      s += v.at(k);
      k++;
    }
    while(l < n){
      t += v.at(l);
      l++;
    }
    
    w.at(j) = max((s - t), - (s - t));
    j++;
  }
  
  sort(w.begin(), w.end());
  cout << w.at(0) << endl;
}
  

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

int main(){
    int h,w;
    cin >> h >> w;
    char a[h][w];
    int count=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> a[i][j];
            if(a[i][j]=='#')count++;
        }
    }
    if(count==h+w-1){
        puts("Possible");
        return 0;
    }
    puts("Impossible");
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>
#include<map>
using namespace std;
#define fr first
#define sc second
typedef pair < int , int > Pi;
struct edge{
  int limit, cost;
  vector< int > node , cango;
} info[5001];
int n, k;
bool used[5001];
 
int Dijkstra(){
  priority_queue< Pi , vector< Pi > , greater< Pi > > que;
  for( que.push(Pi(0,0)) ; !que.empty() ; que.pop()){
    Pi p = que.top();
    if(used[p.sc]++) continue;
    if(p.sc == n - 1) return p.fr;
    for(int i = 0 ; i < info[p.sc].cango.size() ; i++ ){
      que.push(Pi(p.fr + info[p.sc].cost,info[p.sc].cango[i]));
    }
  }
}
int main(){
  cin >> n >> k;
  for(int i = 0 ; i < n ; i++ ){
    cin >> info[i].cost >> info[i].limit;
  }
  for(int i = 0, a, b ; i < k ; i++ ){
    cin >> a >> b;
    info[--a].node.push_back(--b);
    info[b].node.push_back(a);
  }
 
  queue< Pi > que;
  for(int i = 0 ; fill_n(used, 5001, false), i < n ; i++ ){
    for( que.push(Pi(i,info[i].limit)) ; !que.empty() ; que.pop() ){
      Pi p = que.front();
      if(!p.sc) continue;
      for(int j = 0 ; j < info[p.fr].node.size() ; j++ ){
        if(!used[info[p.fr].node[j]]++){
          info[i].cango.push_back(info[p.fr].node[j]);
          que.push(Pi(info[p.fr].node[j],p.sc-1));
        }
      }
    }
  }
  cout << Dijkstra() << endl;
}

Measured memory_bytes: 200828
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        long[] a = Console.ReadLine().Split().Select(i => long.Parse(i)).ToArray();
        long[] l = new long[n];
        long[] r = new long[n + 1];
        l[0] = 0;
        for (int i = 1; i < n; i++)
        {
            l[i] = Gcd(l[i - 1], a[i - 1]);
        }
        for (int i = n - 1; 0 <= i; i--)
        {
            r[i] = Gcd(a[i], r[i + 1]);
        }
        r[n] = 0;

        List<long> ans = new List<long>();
        for (int i = 0; i < n; i++)
        {
            ans.Add(Gcd(l[i], r[i + 1]));
        }
        Console.WriteLine(ans.Max());
    }

    static long Gcd(long a, long b)
    {
        if (a == 0) return b;
        else if (b == 0) return a;

        long r = a % b;
        if (r == 0) return b;
        return Gcd(b, r);
    }
}

Measured memory_bytes: 29276
#include<iostream>
using namespace std;
int main(){
  int n,sans,lans,nk,count=0;
  while(cin>>n){
    nk = n;
    for(int i=nk-1;i>=2;i--){
      for(int j=1;j<=i;j++){
	if(i%j==0) count++;
      }
      if(count==2){
	cout << i << ' ';
	count = 0;
	break;
      }
      else count = 0;
    }
    for(int i=nk+1;i<=50021;i++){
      for(int j=1;j<=i;j++){
	if(i%j==0) count++;
      }
      if(count==2){
	cout << i << endl;
	count = 0;
	break;
      }
      else count = 0;
    }
  }
    return 0;
}

Measured memory_bytes: 1156
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

int main() {
	IOS;
	int n, k, c;
	cin >> n >> k >> c;
	string s;
	cin >> s;
	string t(s);
	vector<int> a(n, 0);
	reverse(all(t));
	int h = 0;
	//a[0] = t[0] == 'o';
	FOR(i, 0, n) {
		if (i - 1 >= 0) {
			a[i] = a[i - 1];
		}
		
		if (h == 0 && t[i] == 'o') {
			a[i]++;
			h = c + 1;
		}
		h--;
		chmax(h, 0);
	}
	reverse(all(a));
	vector<int> res;
	int tmp = 0;
	h = 0;
	REP(i, n) {
		if (s[i] == 'o') {
			int t2 = tmp;
			int t3 = max(i+1,i + h);
			if (t3 < n) {
				t2 += a[t3];
			}
			if (t2 < k) {
				res.push_back(i+1);
			}
		}
		if (h == 0 && s[i] == 'o') {
			tmp++;
			h = c + 1;
		}
		h--;
		chmax(h, 0);
		
	}
	REP(i, res.size()) {
		put(res[i]);
	}
	return 0;
}

Measured memory_bytes: 3596
use std::cmp;
use std::collections::HashMap;
use std::io::*;
use std::str::FromStr;
use std::string::String;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}

#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<std::cmp::Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> std::cmp::Ordering {
        other.0.cmp(&self.0)
    }
}

struct SegmentTree<Monoid, Operator> {
    size: usize,
    node: Vec<Monoid>,
    f: Operator,
    e: Monoid,
}

impl<Monoid, Operator> SegmentTree<Monoid, Operator>
where
    Operator: Fn(Monoid, Monoid) -> Monoid,
    Monoid: Copy,
{
    pub fn new(n: usize, f: Operator, e: Monoid) -> Self {
        let mut size = 1;
        while size < n {
            size *= 2
        }

        SegmentTree {
            size: size,
            node: vec![e; size * 2],
            f: f,
            e: e,
        }
    }

    pub fn update(&mut self, idx: usize, x: Monoid) {
        let mut k = idx + self.size - 1;
        self.node[k] = x;
        while k > 0 {
            k = (k - 1) / 2;
            self.node[k] = (self.f)(self.node[2 * k + 1], self.node[2 * k + 2]);
        }
    }

    pub fn query(&self, a: usize, b: usize) -> Monoid {
        return self._query(a, b, 0, 0, self.size);
    }

    fn _query(&self, a: usize, b: usize, idx: usize, l: usize, r: usize) -> Monoid {
        if r <= a || b <= l {
            return self.e;
        }

        if a <= l && r <= b {
            return self.node[idx];
        }

        let xl: Monoid = self._query(a, b, 2 * idx + 1, l, (l + r) / 2);
        let xr: Monoid = self._query(a, b, 2 * idx + 2, (r + l) / 2, r);

        return (self.f)(xl, xr);
    }
}

fn main() {
    let (n, q): (usize, usize) = (read(), read());
    let mut seg = SegmentTree::<i32, _>::new(n, |x, y| std::cmp::min(x, y), 2147483647);

    for _ in 0..q {
        let (com, x, y): (usize, usize, usize) = (read(), read(), read());

        if com == 0 {
            seg.update(x, y as i32);
        } else {
            println!("{}", seg.query(x, y + 1));
        }
    }
}


Measured memory_bytes: 5052
#include<stdio.h>
#include<string.h>
main(){
	char o[100],e[100];
//	memset(o,'#',sizeof(o));
//	memset(e,'#',sizeof(e));
//	puts(e);
	int i=0,j=0,l;
	scanf("%s\n%s",o,e);
	l=(strlen(o)>strlen(e))?strlen(o):strlen(e);
	while(l--){
	 if (i<strlen(o)){
	 
		printf("%c",o[i]);
	    i++;}
	  if (j<strlen(e)){
	    printf("%c",e[j]);
	    j++;}
	}
}

Measured memory_bytes: 128
# https://beta.atcoder.jp/contests/abc048/tasks/abc048_b


def div(n, div):
    if n >= 0:
        return n // div + 1
    else:
        return 0


def solve():
    a, b, x = map(int, input().split())
    print(div(b, x) - div(a - 1, x))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N;cin >> N;
    deque <ll> A(N);
    loop(i,0,N) cin >> A[i];
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    ll sum=A[0];
    queue <int > Q;
    Q.push(A[1]);
    A.pop_front(); A.pop_front();
    while (!Q.empty())
    {
        ll val=Q.front();
        Q.pop();
        if (A.size())
        {
            Q.push(A.front());
            A.pop_front();
            sum+=val;
        }
        if (A.size())
        {
            Q.push(A.front());
            A.pop_front();
            sum+=val;
        }
    }
    // for (int i=1; i<N; ++i) sum+=A[i];
    cout << sum << "\n";
    return 0;
}

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

int main(){
    long long x, a, b;
    cin >> x >> a >> b;

    if(b-a <= 0) printf("delicious\n");
    else if(0 < b-a and b-a <= x)printf("safe\n");
    else if(b-a > x)printf("dangerous\n");

    return 0;
}

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

int main() {
  int n;
  cin>>n;
  int h[100005];
  rep(i,n) cin>>h[i];
  int ans=0,cnt=0; 
  rep(i,n-1) {
    if (h[i]>=h[i+1]) cnt++;
    else {
      ans=max(cnt,ans);
      cnt=0;
    }
  }
  ans=max(cnt,ans);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 640
n=int(input())
s=[]
for i in range(n):
    s.append(input())

m=int(input())
t=[]
for i in range(m):
    t.append(input())

cnt = 0

for i in s:
    x = s.count(i) - t.count(i)
    cnt = max(cnt,x)

print(cnt)


Measured memory_bytes: 3060
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define debug int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<int, Pi> V;
typedef vector<ll> VE;
const ll mod = 1e9 + 7; //10^9+7


int main(){
    ll a[100002];
    ll n;
    cin >> n;
    map<ll, ll> mp;
    REP(i, n){
        cin >> a[i];
        mp[a[i]]++;
    }
    ll cnt = 0;
    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        if(itr->second % 2)cnt++;
    }
    print(cnt);
}

Measured memory_bytes: 7296
import sys
def input(): return sys.stdin.readline().strip()

def main():
    N = int(input())
    n = int(N ** 0.5) + 1
    ans = 10**18
    for a in range(n, 0, -1):
        if N % a != 0: continue
        b = str(N // a)
        print(len(b))
        return

if __name__ == "__main__":
    main()


Measured memory_bytes: 63268
import java.util.*;

public class Main {
  
  private static int MOD = 1_000_000_007;
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    
    long ans = 1;
    for (long i = 2; i*i <= M; i++) {
      if (M % i == 0) {
        int cnt = 0;
        while (M % i == 0) {
          cnt++;
          M /= i;
        }
        ans *= combmod(cnt + N - 1, N - 1);
        ans %= MOD;
      }
    }
    
    if (M != 1) {
      ans *= combmod(N, 1);
      ans %= MOD;
    }
    
    System.out.println(ans);
  }
  
  private static long combmod(int n, int r) {
    if (r > n - r) {
      return combmod(n, n - r);
    }
    
    long combMul = 1;
    long combDiv = 1;
    for (int i = 0; i < r; i++) {
      combMul *= n - i;
      combMul %= MOD;
      combDiv *= i + 1;
      combDiv %= MOD;
    }
    return combMul * powmod(combDiv, MOD - 2) % MOD;
  }
  
  private static long powmod(long a, int n) {
    if (n == 0) {
      return 1;
    }
    
    if (n % 2 == 0) {
      int halfN = n / 2;
      long half = powmod(a, halfN);
      return half * half % MOD;
    } else {
      return a * powmod(a, n-1) % MOD;
    }
  }
}


Measured memory_bytes: 23764
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <deque>
using namespace std;

int main()
{
	int money[100],pay[100],count[100] = {0},i = 0;

	while(1)
	{
		cin>>pay[i];
		if(pay[i] == 0)break;
		money[i] = 1000 - pay[i];

		while(money[i] >= 1)
		{
			if(money[i] >= 500)
			{
				money[i] -= 500;
				count[i]++;
			}
			else if(money[i] >= 100)
			{
				money[i] -= 100;
				count[i]++;
			}
			else if(money[i] >= 50)
			{
				money[i] -= 50;
				count[i]++;
			}
			else if(money[i] >= 10)
			{
				money[i] -= 10;
				count[i]++;
			}
			else if(money[i] >= 5)
			{
				money[i] -= 5;
				count[i]++;
			}
			else if(money[i] >= 1)
			{
				money[i] -= 1;
				count[i]++;
			}
		}
	i++;
	}
	for(int j=0; j<i; j++)
		cout<<count[j]<<endl;

	return 0;

}

Measured memory_bytes: 1156
#include<iostream>
using namespace std;
int main()
{
	string a="CODEFESTIVAL2016",s;
	int counter=0;
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		if(a[i]!=s[i])counter++;
	}
	cout<<counter<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(raw_input())
#stable = 1

class Card():
    __slots__ = ('suit', 'value')

#mergeSort
A = [Card() for _ in xrange(n)]
#quickSort
B = [Card() for _ in xrange(n)]

s = set()
for i in xrange(n):
    a = raw_input().split()
    A[i].suit = a[0]
    B[i].suit = a[0]
    A[i].value = int(a[1])
    B[i].value = int(a[1])
    s.add(int(a[1]))
'''
def merge(A, left, mid, right):
    n1 = mid - left
    n2 = right - mid
    L = [0] * (n1+1) 
    R = [0] * (n2+1)
    L[:n1] = A[left:mid]
    R[:n2] = A[mid:right]
    #for i in xrange(n1):
    #    L[i] = A[left + i]
    #for i in xrange(n2):
    #    R[i] = A[mid + i]
    L[n1] = Card()
    R[n2] = Card()
    L[n1].value = float('inf')
    R[n2].value = float('inf')
    i = 0
    j = 0
    for k in xrange(left,right):
        if L[i].value <= R[j].value:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
    return 0

def mergeSort(A, left, right):
    if right - left > 1:
        mid = int((left + right) / 2)
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)
    return 0
'''
def partition(A, p, r):
    x = A[r].value
    i = p-1
    for j in xrange(p,r):
        if A[j].value <= x:
            i += 1
            tmp = A[i]
            A[i] = A[j]
            A[j] = tmp
    tmp = A[i+1]
    A[i+1] = A[r]
    A[r] = tmp
    return i+1

def quickSort(A,p,r):
    if p < r:
        q = partition(A, p, r)
        quickSort(A, p, q-1)
        quickSort(A, q, r)
    return 0

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

for i in s:
    if [d.suit for d in A if d.value == i] != [d.suit for d in B if d.value == i]:
        print('Not stable')
        break
else:
    print('Stable')

#for i in xrange(n):
#    if A[i].suit != B[i].suit:
#        stable = 0
for i in xrange(n):
    print B[i].suit, B[i].value

Measured memory_bytes: 84984
// +build ignore
package main

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

func solve(sc *scanner, wr *bufio.Writer) int {
	N := sc.i()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = sc.i()
	}

	M := 1000005

	c := make([]int, M)
	for _, x := range A {
		if c[x] != 0 {
			c[x] = 2
			continue
		}
		for i := x; i < M; i += x {
			c[i]++
		}
	}

	ans := 0
	for _, x := range A {
		if c[x] == 1 {
			ans++
		}
	}

	fmt.Println(ans)
	return 0
}

func main() {
	sc := newScanner(os.Stdin)
	wr := bufio.NewWriter(os.Stdout)
	ret := solve(sc, wr)
	wr.Flush()
	os.Exit(ret)
}

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}


Measured memory_bytes: 13112
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <numeric>
#define MODD 1000000007
#define ll long long
using namespace std;

bool HasBit(ll x, int pos) {
    return ((x>>pos)&1);
}

int main() {
    int N;
    cin>>N;
    vector<int> count_ones(62,0);
    vector<int> count_zeros(62,0);
    ll ans = 0;
    for(int i=1;i<=N;i++) {
        ll x;
        cin>>x;
        for(int i=0;i<=61;i++) {
            ll modval = (1ll<<i)%MODD;
            if (HasBit(x,i)) {
                ans += count_zeros[i]*modval%MODD;
                count_ones[i]++;
            } else {
                ans += count_ones[i]*modval%MODD;
                count_zeros[i]++;
            }
        }
        ans %= MODD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	
	N := ScanInt(scanner)
	A := make([]int, N)
	for i := 0; i < N; i++ {
	    A[i] = ScanInt(scanner)
	}
	
	ans := 1
	for i := 0; i < N - 1; {
	    next := i
	    for next + 1 < N && A[i] == A[next + 1] {
	        next++
	    }
	    
	    if next + 1 >= N - 1 {
	        break
	    }
	    
        plus := false
        if A[next] < A[next + 1] {
            plus = true
        }
        next++
        
        for next < N {
            if plus && A[next - 1] > A[next] {
                break
            }
            if !plus && A[next - 1] < A[next] {
                break
            }
            next++
        }
        if next >= N {
            break
        }
	    i = next
	    
	    ans++
	}
	fmt.Println(ans)
	
}

func ScanInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func ScanFloat64(scanner *bufio.Scanner) float64 {
	scanner.Scan()
	f, e := strconv.ParseFloat(scanner.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func ScanText(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

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

func Min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Abs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}


Measured memory_bytes: 3072
#include<iostream>
using namespace std;
int main(){
    int S,h,m,s;
    cin >> S;
    h = S/3600;
    m = (S-3600*h)/60;
    s = S-3600*h-60*m;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}


Measured memory_bytes: 3100
#include <cstdio>


int main(){
    int xflag = 0;
    int yflag = 0;
    int W,H,x,y,r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);   
    int W_max = W - r;
    int H_max = H - r;
    if(x<=W_max && x>=r){
        xflag=1;
    }
    if(y<=H_max && y>=r){
        yflag=1;
    }

    if(xflag==1 && yflag==1){
        puts("Yes");
    }else{
        puts("No");
    }
    return 0;
}

Measured memory_bytes: 1012
#include<stdio.h>

int main(void){
  int i;
  char c, t[200001];
  i = 0;
  while((c = getchar()) != EOF){
    if(c == '?'){
      t[i++] = 'D';
    }
    else{
      t[i++] = c;
    }
  }
  t[i] = '\0';
  
  printf("%s", t);
  
  return 0;
}


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


int main(void){

  double a, b, c, d, e, f;
  double x, y;


  while(scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f)!=EOF){

    x = (b*f-c*e)/(b*d-a*e);
    y = (c*d-a*f)/(b*d-a*e);

    x *= 1000;
    y *= 1000;
    if(fabs(x)<0.5) x = 0;
    else x = round(x);
    if(fabs(y)<0.5) y = 0;
    else y = round(y);



    printf("%.3f %.3f\n", x/1000, y/1000);

  }

  
  return(0);
}



Measured memory_bytes: 2100
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
long long n, a, b, s, x, y, v[55], c[55][55]={1};
int main() {
	int i, j;
	cin>>n>>a>>b;
	for(i=0; i<n; i++) cin>>v[i];
	sort(v, v+n);
	for(i=n-1; i>=n-a; i--) s += v[i];
	printf("%.9f\n", 1.*s/a);
	x = upper_bound(v, v+n, v[n-a]) - lower_bound(v, v+n, v[n-a]);
	for(i=1; i<=x; i++) {
		c[i][0] = 1;
		for(j=1; j<=x; j++) c[i][j] = c[i-1][j-1] + c[i-1][j];
	}
	if(v[n-a] != v[n-1]) {
		y = upper_bound(v+n-a, v+n, v[n-a]) - lower_bound(v+n-a, v+n, v[n-a]);
		cout<<c[x][y];
	} else {
		s = 0;
		for(i=a; i<=min(x, b); i++)
			s += c[x][i];
		cout<<s;
	}
	return 0;
}

Measured memory_bytes: 256
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef vector<ll> vi;
typedef vector<long long> vl;
typedef pair<ll, ll> pi;
typedef vector<pair<ll, ll>> vpi;

//const long long INF = 1LL << 55;

#define itn ll
#define endl '\n'
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(ll i = 0;i < n;i++)
#define rep(i,n) for(ll i = 0;i < n;i++)
#define flush fflush(stdout)
#define rrep(i,n) for(ll i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define ioboost cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, ll mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

int main(void){
    int n;cin >> n;
    vector<ll> a(n);rep(i,n)cin >> a[i];
    reverse(all(a));
    long long ans = a[0];
    for(int i = 0;i < n;i++){
        if(a[i] > n - 1 - i){
            cout << -1 << endl;
            return 0;
        }else if(i){
            if(a[i-1] - a[i] > 1){
                cout << -1 << endl;
                return 0;
            }else if(a[i-1] - a[i] == 1){
                continue;
            }else{
                ans += a[i];
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1920
#include<stdio.h>
#define N 1001
#define M 2097125

int i,j,k,l,n,m[N][N],p[N];

int min(int a, int b){
  if(a >= b) return b;
  else return a;
}

void matrixChain(){
  for(i = 1; i <= n; i++)
    m[i][i] = 0;
  for(k=2; k<=n; k++){
    for(i=1; i<=n; i++){
      j = i+k-1;
      m[i][j] = M;
      for(l=i; l<=j; l++)
				m[i][j] = min(m[i][j],m[i][l]+m[l+1][j]+p[i-1]*p[l]*p[j]);
    }
  }
}

int main(){
  scanf("%d",&n);
  for(i=1; i<=n; i++)
    scanf("%d %d",&p[i-1],&p[i]);
  matrixChain();
  printf("%d\n",m[1][n]);

  return 0;
}



Measured memory_bytes: 2204
n = int(input())
from sys import exit
if n == 1:
  print(0)
  exit()

from collections import defaultdict as dd
dic_list = [{}, {}, {2: 1}]
def prime_factrization(num):  
  dic = dd(lambda: 0)
  for i in range(2, int(num**0.5) + 2):
    mod = num % i
    while mod == 0:
      num //= i
      dic[i] += 1
      mod = num % i
    if num == 1:
      break
  else:
    if num != 1:
      dic[num] += 1
  return dic

dic = dd(lambda: 0)
for i in range(2, n+1):
  pf = prime_factrization(i)
  for j in range(2, 100):
    dic[j] += pf[j]
#print(dic)

#75 = 5 * 5 * 3
up3_divisor = 0
for num in dic.values():
  if num >= 2:
    up3_divisor += 1
up5_divisor = 0
for num in dic.values():
  if num >= 4:
    up5_divisor += 1
up15_divisor = 0
for num in dic.values():
  if num >= 14:
    up15_divisor += 1
up25_divisor = 0
for num in dic.values():
  if num >= 24:
    up25_divisor += 1
up75_divisor = 0
for num in dic.values():
  if num >= 74:
    up75_divisor += 1

import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
ans = 0
if up75_divisor >= 1:
  ans += combinations_count(up75_divisor, 1) #75
if up25_divisor >= 1:
  ans += combinations_count(up25_divisor, 1) * (combinations_count(up3_divisor, 1) - 1) #25 * 3
if up15_divisor >= 1:
  ans += combinations_count(up15_divisor, 1) * (combinations_count(up5_divisor, 1) - 1) #15 * 5
if up5_divisor >= 2:
  ans += combinations_count(up5_divisor, 2) * (combinations_count(up3_divisor, 1) - 2) #5 * 5 * 3
print(ans)

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

int main()
{
   string s;
   cin >> s;

   int size = s.size();
   ll ans = 0;

   rep(i, 1<< size-1){
      string rem = s;
      int cnt = 1;
      rep(j, size -1){
         if(i >> j & 1)
         {
            //+入れる
            ll target = stoll(rem.substr(0,cnt));
            ans += target;
            rem = rem.substr(cnt);
           // cout << target << " (" << rem << ")" <<endl;
            cnt = 1;
         }
         else 
         {
            //+入れない
            cnt++;
         }
      }
     // cout << "--" << rem << "--" << endl;
      if(rem.size())
         ans += stoll(rem);
   }

   cout << ans << endl;
}

Measured memory_bytes: 256