akhauriyash/Code-Regression huggingface dataset:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())

o=int()

if (b-a >k):
  o = 1
elif (c-a >k):
  o = 1
elif (d-a >k):
  o = 1
elif (e-a >k):
  o = 1
  
elif (c-b >k):
  o = 1
elif (d-b >k):
  o = 1
elif (e-b >k):
  o = 1
elif (d-c >k):
  o = 1
elif (e-c >k):
  o = 1
elif (e-d >k):
  o = 1
else:
  o = 0

if( o == 1 ):
  print (':(')
else:
  print ('Yay!')
  

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 2*(int)1e5 + 10;

int n, dp[N][4];
string s;

int mapping(char c){
   if (c == 'D'){
      return 0;
   }
   return 1;
}

int solve(int idx, int prev){
   if (idx >= n){
      return 0;
   }
   int &ans = dp[idx][1+prev];
   if (ans != -1){
      return ans;
   }
   ans = 0;

   if (s[idx] != '?'){
      int i = mapping(s[idx]);
      if (i == 1){//1 is P
         smax(ans, solve(idx +1, i));
      }
      else{//i is D
         smax(ans, 1 + (prev == 1) + solve(idx+1, i));
      }
      return ans;
   }

   for(int i: {0, 1}){
      if (i == 1){//1 is P
         smax(ans, solve(idx +1, i));
      }
      else{
         smax(ans, 1 + (prev == 1) + solve(idx+1, i));
      }
   }
   return ans;
}

char mapping2(int i){
   if (i == 0){
      return 'D';
   }
   assert(i == 1);
   return 'P';
}

string ret;
void trace(int idx, int prev){
   if (idx >= n){
      return ;
   }
   int ans = solve(idx, prev);
   if (s[idx] != '?'){
      int i = mapping(s[idx]);
      if (i == 1){//1 is P
         trace(idx +1, i);
         ret += mapping2(i);
      }
      else{
         trace(idx+1, i);
         ret += mapping2(i);
      }
      return ;
   }
   if (ans == (solve(idx +1, 1))){
      trace(idx+1, 1);
      ret += mapping2(1);
   }
   else{
      trace(idx+1, 0);
      ret += mapping2(0);
   }
}

int32_t main(){_
   
   cin >> s;
   n = (int)(s.size());
   memset(dp, -1, sizeof dp);
   
   int ans = solve(0, -1);
   tr(ans);

   trace(0,-1);
   reverse(ret.begin(), ret.end());
   cout<<ret;

   return 0;
}

Measured memory_bytes: 28772
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

long aCb(long a, long b) {
	long out = 1;
	for (long i = 1; i <= b; i++) {
		out = out * (a + 1 - i) / i;
	}
	return out;
}

long long gcd(long long a, long long b) {
	long long r = -1;
	if (a < b) {
		swap(a, b);
	}
	while (r != 0) {
		r = a % b;
		if (r == 0) {
			return b;
		}
		else {
			a = b;
			b = r;
		}
	}
}

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

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	printf("%c%c%c\n", a[0] - 32, b[0] - 32, c[0] - 32);
}


Measured memory_bytes: 256
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
// const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string a, b;
    cin >> a >> b;
    if(a == "H"){
        if(b == "H"){
            cout << "H" << endl;
        }
        else {
            cout << "D" << endl;
        }
    }
    else {
        if(b == "H"){
            cout << "D" << endl;
        }
        else {
            cout << "H" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from itertools import chain
from functools import reduce
from collections import OrderedDict, Counter, deque
import operator

N = int(input())
W = [input() for _ in range(N)]

def f():
    if len(W) != len(set(W)):
        return False
    p = W[0]
    for n in W[1:]:
        if p[-1] != n[0]:
            return False
        p = n
    return True
print("Yes" if f() else "No")

Measured memory_bytes: 3572
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
using namespace std;

void A() {
	char c; cin >> c;
	if ('a' <= c && c <= 'z') {
		cout << "a" << endl;
	}
	else {
		cout << "A" << endl;
	}
}

void B(){
    int N,K; cin >> N >> K;
    vi vec(N);
    rep(i,N) cin >> vec[i];
    sort(ALL(vec));

    int ans = 0; rep(i,N) ans += vec[i];

    cout << ans << endl;
}

inline char itoc(int i) {
	char c;
	if (i == 0) i += 26;
	c = 'a' + (i - 1);
	return c;
}

void C(){
    ll N; cin >> N;
	string ans = "";
	while (N) {
		int m = N % 26;
		N /= 26;
		if (m == 0) N--;
		ans += itoc(m);
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
}
int main(){
    C();
}

Measured memory_bytes: 3624
#include<stdio.h>
void main(void)
{
  int n;
  int n1,n2,n3;
  scanf("%d",&n);
  n1=n%10;
  n=n/10;
  n2=n%10;
  n=n/10;
  n3=n%10;
  if(n1==7||n2==7||n3==7)
    printf("Yes");
  else
    printf("No");
}

Measured memory_bytes: 1732
#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> p1;
    vector<int> p2;
    vector<int> p3;
    for(int i = 0; i < N; ++i)
    {
        int pi;
        cin >> pi;
        if(pi <= A)
            p1.push_back(pi);
        else if(pi <= B)
            p2.push_back(pi);
        else
            p3.push_back(pi);
    }

    vector<int> p(3);
    p[0] = p1.size();
    p[1] = p2.size();
    p[2] = p3.size();
    sort(p.begin(), p.end());
    cout << p[0] << endl;
    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
#define ll long long
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int main(){
	fastio();
	ll n,a,b;
	cin>>n>>a>>b;
	ll k = abs(a-b);
	if(k%2){
		if(a>b) swap(a,b);
		ll t = a-1;
		ll p = n-b;
		b-=(t);
		a+=(p);
		cout<<min((b)/2+t,(n-a+1)/2+p);


	}else{
		ll t = k/2;
		ll p = min(max(a-1,b-1),max(n-a,n-b));
		cout<<min(t,p);
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
const int maxn=1e4+5,maxm=4e4+5;
const ll inf=1e18;
inline int fa(int u){ return u/2; }
inline int ls(int u){ return u*2; }
inline int rs(int u){ return u*2+1; }
struct heap{
	int hea[maxn],pos[maxn],siz;
	ll *dis;
	heap(ll a[],int n){
		dis=a; siz=n;
		int i;
		for (i=1;i<=n;i++){
			dis[i]=inf; hea[i]=i; pos[i]=i;
		}
	}
	void hswap(int u,int v){
		swap(hea[u],hea[v]);
		pos[hea[u]]=u; pos[hea[v]]=v;
	}
	void update(int u){
		if (u==1) return;
		if (dis[hea[fa(u)]]<=dis[hea[u]]) return;
		hswap(u,fa(u));
		update(fa(u));
	}
	void pushdown(int u){
		int v=u;
		if (ls(u)<=siz&&dis[hea[ls(u)]]<dis[hea[v]]) v=ls(u);
		if (rs(u)<=siz&&dis[hea[rs(u)]]<dis[hea[v]]) v=rs(u);
		if (u==v) return;
		hswap(u,v);
		pushdown(v);
	}
	void change(int u,ll val){
		dis[u]=val;
		update(pos[u]);
		pushdown(pos[u]);
	}
	int pop(){
		hswap(1,siz);
		siz--;
		pushdown(1);
		return hea[siz+1];
	}
};
struct gragh{
	int head[maxn],next[maxm],to[maxm],tot;
	ll wei[maxm],cost[maxm];
	gragh(){
		memset(head,-1,sizeof(head));
		tot=0;
	}
	void clear(){
		memset(head,-1,sizeof(head));
		tot=0;
	}
	void add(int u,int v,ll w,ll c){
		next[tot]=head[u];
		head[u]=tot;
		to[tot]=v;
		wei[tot]=w;
		cost[tot]=c;
		tot++;
	}
	void dijkstra(ll dis[],ll val[],int st,int n){
		heap hp(dis,n);
		hp.change(st,0);
		int i,u,v,ed;
		for (i=1;i<=n;i++) val[i]=inf;
		val[st]=0;
		while (hp.siz){
			u=hp.pop();
			for (ed=head[u];ed!=-1;ed=next[ed])
				if (dis[v=to[ed]]>dis[u]+wei[ed])
					hp.change(v,dis[u]+wei[ed]);
		}
		for (u=1;u<=n;u++) for (ed=head[u];ed!=-1;ed=next[ed])
			if (dis[v=to[ed]]==dis[u]+wei[ed])
			val[v]=min(val[v],cost[ed]);
	}
};
gragh g;
ll dis[maxn],val[maxn];
int main(){
	int n,m,i,u,v;
	ll w,c,ans;
	while (scanf("%d%d",&n,&m)&&(n||m)){
		g.clear();
		for (i=0;i<m;i++){
			scanf("%d%d%lld%lld",&u,&v,&w,&c);
			g.add(u,v,w,c);
			g.add(v,u,w,c);
		}
		g.dijkstra(dis,val,1,n);
		ans=0;
		for (i=1;i<=n;i++) ans+=val[i];
		printf("%lld\n",ans);
	}
	return 0;
}


Measured memory_bytes: 4312
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
#define int long long

signed main() {
    int n;
    cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        int k = n / i;
        ans += (i + k * i) * k / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612
// A - Colorful Transceivers
#include <bits/stdc++.h>
using namespace std;

int main(){
	int a,b,c,d; cin>>a>>b>>c>>d;
	if(abs(a-c) <= d) puts("Yes");
	else if(abs(a-b) <= d && abs(b-c) <= d) puts("Yes");
	else puts("No");
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
vector<ll> edgeList[200010];
ll maxD=0,maxNode=-1;
ll Visit(ll n,ll p,ll d){
    ll ret=0;
    for(auto to:edgeList[n]){
        if(to!=p){
            ret=max(ret,Visit(to,n,d+1));
        }
    }
    if(ret==0 && maxD<d){
        maxD=d;
        maxNode=n;
    }
    return ret+1;
}
ll Diameter(){
    Visit(1,-1,0);
    return Visit(maxNode,-1,0)-1;
}
int main(){
    cin>>N;
    for(ll i=0;i<N-1;i++){
        ll a,b;
        cin>>a>>b;
        edgeList[a].push_back(b);
        edgeList[b].push_back(a);
    }
    if((Diameter()+1)%3==2){
        cout<<"Second";
        return 0;
    }
    cout<<"First";
    return 0;
}

Measured memory_bytes: 26752
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n";const string sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> mvec(size_t a){return vector<T>(a);}template<class T, class... Ts>auto mvec(size_t a, Ts... ts){return vector<decltype(mvec<T>(ts...))>(a, mvec<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}/* 重み付きUnionFind */struct WUnionFind {vector<int> par;vector<int> rank;WUnionFind(int n = 1) {init(n);}void init(int n = 1) {par.resize(n); rank.resize(n);for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;}int root(int x) {if (par[x] == x) {return x;}else {int r = root(par[x]);return par[x] = r;}}bool issame(int x, int y) {return root(x) == root(y);}bool merge(int x, int y) {x = root(x); y = root(y);if (x == y) return false;if (rank[x] < rank[y]) swap(x, y);if (rank[x] == rank[y]) ++rank[x];par[y] = x;return true;}};/* IO高速化 */void fastio(){ios::sync_with_stdio(false);cin.tie(NULL);}
/* ここからコード開始 */

int main(){
  fastio;
  ll N;
  cin >> N;
  ll l, r;
  cin >> l;
  ll ans{};
  rep(i, 0, N-1){
    cin >> r;
    if(l == r && !(l == 0)){
      ans++;
      r = 0;
    }
    l = r;
  }
  cout << ans << rt;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main() {
  int64_t N;
  cin>>N;
  auto k=func(N);
  int ans=0;
  for(auto a:k){
    int t=a.second;
    int d=1;
    int cnt=0;
    while(t>=d){t-=d;d++;cnt++;}
    ans+=cnt;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
template <class T> bool chmax(T &a,const T &b) {if(a<b) {a=b;return 1;} return 0;}
template <class T> bool chmin(T &a,const T &b) {if(b<a) {a=b;return 1;} return 0;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct { template <typename T> operator T() { T x; cin >> x; return x; } } IN;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

vector<bool> is_prime;
void eratosthenes(int N) {
    is_prime.resize(N+1);
    fill(ALL(is_prime),true);
    is_prime[0]=false;
    is_prime[1]=false;
    REPF(i,2,sqrt(N)+1)
        if(is_prime[i])
            for(int j=2; i*j<=N; j++)
                is_prime[i*j]=false;
}
signed main() {
    eratosthenes(200005);
    vector<int> cnt(200005,0);
    int sum=0;
    REPF(i,1,200005) {
        if(i%2==1 && is_prime[i] && is_prime[(i+1)/2]) {
            sum++;
        }
        cnt[i]=sum;
    }
    int Q=IN;
    while(Q--) {
        int l=IN,r=IN;
        cout<<cnt[r]-cnt[l-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 2176
#include<stdio.h>
#include<string.h>
const int maxn=177;

int A[maxn],B[maxn],C[maxn],D[maxn],N,M[maxn][maxn];

bool used[maxn];
int mat[maxn];

bool dfs(int u){ 
        for(int v=1;v<=N;++v) if(M[u][v]){
                if(!used[v]){
                        used[v]=true;
                        if(mat[v]==0 || dfs(mat[v])){
                                mat[v]=u;
                                return true;
                        }   
                }   
        }   
        return false;
}

int main(){
        scanf("%d",&N);
        for(int i=1;i<=N;++i) scanf("%d%d",A+i,B+i);
        for(int i=1;i<=N;++i) scanf("%d%d",C+i,D+i);
        for(int i=1;i<=N;++i) for(int j=1;j<=N;++j) if(A[i]<C[j] && B[i]<D[j]) M[i][j]=1;

        int ans=0;
        for(int i=1;i<=N;++i){
                if(dfs(i)) ++ans;
                memset(used,0,sizeof(used));
        }   

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


Measured memory_bytes: 256
# 2019-11-22 19:46:21(JST)
import sys


def main():
    n, a, b, c, d = [int(x) for x in sys.stdin.readline().split()]
    s = '#' + sys.stdin.readline().rstrip()

    if '##' in s[a+1:c-1] or '##' in s[b+1:d-1]:
        ans = 'No'
    else:
        if c < d:
            ans = 'Yes'
        else:
            # for i in range(b, d+1):
            #     if s[i-1] == s[i] == s[i+1] == '.':
            #         ans = 'Yes'
            #         break
            if '...' in s[b-1:d+2]:
                ans = 'Yes'
            else:
                ans = 'No'
        
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
// 2019/06/03 Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

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

	int a[300000], b[300000];
	for(int i=0; i<N; i++){
		cin >> a[i];
		b[i] = a[i];
	}

	sort(b, b+N);			// 正解を作る

	int D = 0;				// 正解と異なる要素数

	for(int i=0; i<N; i++){
		if(a[i]!=b[i]){
			D++;
		}
	}

	if(D==0){
		cout << 0 << endl;
		return 0;
	}

	int Q;
	cin >> Q;

	for(int i=1; i<=Q; i++){
		int x, y;
		cin >> x >> y;

		if(a[x-1]!=b[x-1]){		// 交換前に異なれば
			D--;
		}
		if(a[y-1]!=b[y-1]){
			D--;
		}

		swap(a[x-1], a[y-1]);		// 交換

		if(a[x-1]!=b[x-1]){		// 交換後に異なれば
			D++;
		}
		if(a[y-1]!=b[y-1]){
			D++;
		}

		if(D==0){
			cout << i << endl;
			return 0;
		}
	}

	cout << -1 << endl;
	return 0;
}



Measured memory_bytes: 5472
def bubble_sort(a,n):
  flag = 1
  cnt = 0
  while flag:
    flag = 0
    for i in range(1,n)[::-1]:
      if a[i] < a[i-1]:
        temp = a[i-1]
        a[i-1] = a[i]
        a[i] = temp
        flag = 1
        cnt += 1
  print(' '.join(map(str,a)))
  print(cnt)
num = int(input())
ar = list(map(int,input().split()))

bubble_sort(ar,num)



Measured memory_bytes: 5600
#include <iostream>
#include <vector>
#include <numeric>
#include <iomanip>

using namespace std;

int main(int argc, char const *argv[])
{
    int N, K;
    cin >> N >> K;
    vector<int> p, psum;
    int in;
    psum.emplace_back(0);
    for (int i = 0; i < N; i++)
    {
        cin >> in;
        p.emplace_back(in);
        psum.emplace_back(psum[i] + in);
    }

    int sum;
    int max = 0;
    int maxi;
    vector<int>::iterator pstart, pend;
    for (int i = K; i <= N; i++)
    {
        pend = psum.begin() + i;
        pstart = pend - K;
        sum = *pend - *pstart;
        
        if (sum > max)
        {
            max = sum;
            maxi = i - K;
        }

    }

    double ans = 0.0;
    for (int i = 0; i < K; i++)
    {
        ans += 0.5 * (1 + p[maxi + i]);
    }
    
    cout <<  fixed  <<  setprecision(12)  <<  ans  << endl;
    
    return 0;
}

Measured memory_bytes: 2036
// Author: Jinhai Chen
#include <cstring>
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int INF = 0x3f3f3f3f;
typedef long long ll;

int a[12];

int main() {
	int b,c,d,e;
	cin>>b>>c>>d>>e;
	a[b]=a[c]=a[d]=a[e]=1;
	if(a[9]&&a[1]&&a[4]&&a[7]) puts("YES");
	else puts("NO");


	return 0;
}














Measured memory_bytes: 256
//https://atcoder.jp/contests/abc138/tasks/abc138_d
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
struct Data{
    ll count=0;
    ll value=0;
    vector<ll> ch;
    vector<ll> pa;
};
vector<Data> node;
void dfs(ll no, ll sum){
    auto& cur=node[no];
    cur.value = sum+cur.count;
    for(auto& nex:cur.ch){
        dfs(nex, cur.value);
    }
}
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-1.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#endif
    ll N,Q; cin>>N>>Q;
    node.resize(N+1);
    for(ll i=1;i<N;++i){
        ll a,b; cin>>a>>b;
        node[a].ch.push_back(b);
        node[b].pa.push_back(a);
    }
    REP(i,Q){
        ll p,x; cin>>p>>x;
        node[p].count += x;
    }
    //rootから
    dfs(1,0);
    for(ll i=1;i<node.size();++i){
        if(i!=1) cout<<" ";
        cout<<node[i].value;
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 33664
#include <iostream>

int main (){
  int h, w;
  std::cin >> h >> w;

  while ((h!=0)&&(w!=0))
    {
      for (int i=0; i<h; i++)
        {
          for (int j=0; j<w; j++)
            {
              if (((i+j) % 2) == 0)
                std::cout << '#';
              else
                std::cout << '.';
            }
          std::cout << std::endl;
        }
        std::cout << std::endl;
      std::cin >> h >> w;
    }
}



Measured memory_bytes: 3100
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <queue>

using namespace std;
using llint = long long int;
#define int long long int

signed main()
{
  int a, b;
  cin >> a >> b;
  if (a + b == 15)
  {
    cout << "+" << endl;
  }
  else if (a * b == 15)
  {
    cout << "*" << endl;
  }
  else
  {
    cout << "x" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

int main()
{
	fastio
	LL n, i, ans=0;
	cin>>n;
	LL a[n+1]={0}, b[n+1]={0}, c[n+1]={0};
	for(i=1; i<=n; i++)
		cin>>a[i];
	for(i=1; i<=n; i++)
		cin>>b[i];
	for(i=1; i<n; i++)
		cin>>c[i];
	for(i=1; i<=n; i++){
		ans+=b[a[i]];
		if(i>1 && a[i]==a[i-1]+1)
			ans+=c[a[i]-1];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
n, y = (int(x) for x in input().split())

ans = "-1 -1 -1"
for a in range(n+1):
    if ans != "-1 -1 -1":
        break
    for b in range(n+1):
        c = int((y - 10000 * a - 5000 * b) / 1000)
        if c >= 0 and a + b + c == n:
            ans = "{} {} {}".format(a, b, c)
            break
        elif c < 0:
            break
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

int N, power[12], a[3] = { 3, 5, 7 }, cnt;

int main() {
	cin >> N;
	power[0] = 1; for (int i = 1; i <= 10; i++) power[i] = power[i - 1] * 3;
	for (int i = 1; i <= 9; i++) {
		for (int j = 0; j < power[i]; j++) {
			long long G = 0, T = 1; int bit[3] = { 0, 0, 0 };
			for (int k = 0; k < i; k++) {
				int c1 = (j / power[k]) % 3;
				bit[c1] = 1; G += T * a[c1]; T *= 10;
			}
			if (G <= N && bit[0] + bit[1] + bit[2] == 3) cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

int main() {
	int seq[10] = {};
	string str;
	while (cin >> str) {
		for (int i = 0; i < 10; i++)
			seq[i] = str[i] - '0';
		int num = 9;
		while (num > 0) {
			for (int i = 0; i < num; i++) {
				seq[i] = seq[i] + seq[i+1];
				if (seq[i] > 9)
					seq[i] -= 10;
			}
			num--;
		}
		cout << seq[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
 
template <typename T> T inf;
template <> constexpr int inf<int> = 1e9;
template <> constexpr ll inf<ll> = 1e18;

using weight = ll;

struct edge {
    int to;
    weight cap;
    int rev;
};

using edges = std::vector<edge>;
using graph = std::vector<edges>;

void add_edge(graph& g, int from, int to, weight cap) {
    g[from].push_back(edge{to, cap, static_cast<int>(g[to].size())});
    g[to].push_back(edge{from, 0, static_cast<int>(g[from].size()-1)});
}

void bfs(graph& g, std::vector<int>& level, int s) {
    for(int i = 0; i < (int)level.size(); ++i) {
        level[i] = -1;
    }
    level[s] = 0;
    std::queue<int> que;
    que.push(s);
    while(!que.empty()) {
        int v = que.front(); que.pop();
        for(int i = 0; i < (int)g[v].size(); ++i) {
            edge& e = g[v][i];
            if(e.cap > 0 && level[e.to] < 0) {
                level[e.to] = level[v] + 1;
                que.push(e.to);
            }
        }
    }
}

weight dfs(graph& g, std::vector<int>& level, std::vector<int>& iter, int v, int t, weight f) {
    if(v == t) {
        return f;
    }
    for(int& i = iter[v]; i < (int)g[v].size(); ++i) {
        edge& e = g[v][i];
        if(e.cap > 0 && level[v] < level[e.to]) {
            weight d = dfs(g, level, iter, e.to, t, std::min(f, e.cap));
            if(d > 0) {
                e.cap -= d;
                g[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

weight max_flow(graph& g, int s, int t) {
    weight flow = 0;
    std::vector<int> level(g.size(), -1);
    std::vector<int> iter(g.size(), 0);
    weight INF = inf<ll>;
    while(true) {
        bfs(g, level, s);
        if(level[t] < 0) {
            return flow;
        }
        for(int i = 0; i < (int)iter.size(); ++i) {
            iter[i] = 0;
        }
        weight f;
        while((f = dfs(g, level, iter, s, t, INF)) > 0) {
            flow += f;
        }
    }
}

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; ++i) {
        cin >> a[i];
    }

    graph g(N + 2);
    int const source = N;
    int const sink = source + 1;
    ll res = 0;
    for(int i = 0; i < N; ++i) {
        if(a[i] <= 0) {
            add_edge(g, source, i, -a[i]);
        } else {
            add_edge(g, i, sink, a[i]);
            res += a[i];
        }
        for(int j = i + (i + 1); j < N; j += (i + 1)) {
            add_edge(g, i, j, inf<ll>);
        }
    }
    res -= max_flow(g, source, sink);
    cout << res << endl;
}




Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int t = sc.nextInt();
    
    int stack1 = 0;
    int stack2 = sc.nextInt();
    int ans = t;
    
    for(int i = 1; i < n; i++) {
      stack1 = sc.nextInt();
      if(stack1 < stack2 + t) ans += (stack1 -stack2);
      else ans += t;
      stack2 = stack1;
    }
    
    System.out.println(ans);
  }
}


Measured memory_bytes: 58492
#include<iostream>
#include<algorithm>
#include<vector>
#define MAXV 10001
#define MAXE 100001
using namespace std;

int main() {
	int i, j, v, e, s, t, isVisited[MAXV] = {};
	vector<int*> ntopa[MAXV];
	vector<int*>::iterator itv;


	cin >> v >> e;
	for (i = 0; i < e; i++) {
		cin >> s >> t;
		ntopa[t].push_back(&isVisited[s]);
	}

	i = -1;
	while (1) {
		++i %= v;
		if (isVisited[i])continue;
		for (itv = ntopa[i].begin(); itv != ntopa[i].end(); itv++) {
			if (*(*itv) == 0)break;
		}
		if (itv == ntopa[i].end()) {
			isVisited[i] = 1;
			cout << i << endl;
			i = 0;
			for (j = 0; j < v; j++) {
				if (isVisited[j] == 0)break;
			}
			if (j == v) return 0;
		}
	}


	return 0;
}

Measured memory_bytes: 3856
#include<stdio.h>

int main(){
  int x,s,t;

scanf("%d",&x);
for(s=1;s<=x;s++){t=s;
  if(s%3==0||s%10==3){printf(" %d",s);}
else{while (1){t=t/10;
    if(t%10==3){printf(" %d",s);break;}
 else if(t==0){break;}}
}
}
   printf("\n");
return 0;
}

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

// Shortening code
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;

// Macros
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = a; i >= b; i--)

const int nax = 1e5 + 5;
vector<vi> adjList(nax);
vi in_degree(nax);
vi dist(nax);

void dfs(int u)
{
    for (auto v : adjList[u])
    {
        dist[v] = max(dist[v], dist[u] + 1);
        in_degree[v]--;
        if (in_degree[v] == 0)
        {
            dfs(v);
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // Your code
    int n, m;
    cin >> n >> m;

    REP(i, 0, m)
    {
        int a, b;
        cin >> a >> b;
        adjList[a].PB(b);
        in_degree[b]++;
    }
    REP(i, 1, n + 1)
    {
        adjList[0].PB(i);
        in_degree[i]++;
    }
    dfs(0);
    cout << *max_element(dist.begin(), dist.end()) - 1 << endl;
    return 0;
}

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

int main(){
	int A,B,C,D;
	cin>>A>>B>>C>>D;
	if(B<C || D<A){ // min{B,D} < max{A,C}
		cout<<0<<endl;
	}else{
		if(C<=A && B<=D) cout<<B-A<<endl; // min{B,D}=B, max{A,C}=A
		else if(A<=C && D<=B) cout<<D-C<<endl; // min{B,D}=D, max{A,C}=C
		else if(B>=C && B<=D) cout<<B-C<<endl; // min{B,D}=
		else if(D>=A && A>=C) cout<<D-A<<endl;
		else cout<<0<<endl;
	}
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
using namespace std;
const int MAXN = 100005;
const int INF = (LL)1e9 + 5;
const LL MOD = 998244353;

#define pos first
#define col second

int N, M;
LL dp[MAXN][2];
vector<PII> row[MAXN], col[MAXN];

int grid(int i, int j) {
	auto it = upper_bound(row[i].begin(), row[i].end(), (PII){j, -1});
	return it != row[i].end() && it->pos == j ? it->col : -1;
}

bool conflict(int a, int b) {
	return a != -1 && b != -1 && a != b;
}

LL qpow(LL a, LL p) {
	if (p == 0) return 1;
	LL tmp = qpow(a, p >> 1);
	tmp = tmp * tmp % MOD;
	if (p & 1) return tmp * a % MOD;
	return tmp;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		row[a].push_back({b, c});
		col[b].push_back({a, c});
	}
	
	for (int i = 0; i < N; i++) {
		sort(row[i].begin(), row[i].end());
		sort(col[i].begin(), col[i].end());
	}
	
	dp[0][0] = grid(0, 0) != 1;
	dp[0][1] = grid(0, 0) != 0;
	for (int i = 1; i < N; i++) {
		LL cnt = i - 1;
		bool ok = true, odd = false, even = false;
		for (PII &p : row[i]) {
			int r = i, c = p.pos;
			if (c >= i - 1) break;
			
			int a = grid(r, c), b = grid(c, r);
			bool diff = a != -1 && b != -1 && a != b;
			bool same = a != -1 && b != -1 && a == b;
			if (c == i - 2) {
				if (diff) odd = true;
				if (same) even = true;
			}
			else {
				if (diff) ok = false;
			}
			
			cnt--;
		}
		for (PII &p : col[i]) {
			int r = p.pos, c = i;
			if (r >= i - 1) break;
			
			int a = grid(r, c), b = grid(c, r);
			if (b == -1) cnt--;
		}
//		cout << i << " -> " << cnt << "\n";
		if (!ok) break;
		
		int lc = grid(i, i - 1), uc = grid(i - 1, i), mc = grid(i, i);
		for (int l = 0; l < 2; l++) {
			for (int u = 0; u < 2; u++) {
				for (int m = 0; m < 2; m++) {
					if (conflict(l, lc) || conflict(u, uc) || conflict(m, mc)) continue;
					int pre = (l + u + m) % 2, side = pre;
					if (side == 0 && odd)  continue;
					if (side == 1 && even) continue;
					dp[i][m] = (dp[i][m] + dp[i - 1][pre]) % MOD;
				}
			}
		}
		
		dp[i][0] = dp[i][0] * qpow(2, cnt) % MOD;
		dp[i][1] = dp[i][1] * qpow(2, cnt) % MOD;
		
//		cout << i << " -> " << dp[i][0] << " " << dp[i][1] << "\n";
	}
	
	cout << (dp[N - 1][0] + dp[N - 1][1]) % MOD << "\n";
	
	return 0;
}


Measured memory_bytes: 9728
package main

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

func main() {
	sc := NewScanner()
	N, H := sc.NextInt(), sc.NextInt()
	a := make([]int, N)
	b := make([]int, N)
	mxA := 0

	p := 0
	sumP := 0
	for i := 0; i < N; i++ {
		a[i], b[i] = sc.NextInt(), sc.NextInt()
		if mxA < a[i] {
			mxA = a[i]
		}
	}

	sort.Ints(b)
	for i := N - 1; i >= 0; i-- {
		if mxA < b[i] {
			p++
			sumP += b[i]
			if sumP >= H {
				fmt.Println(N - i)
				return
			}
		}
	}

	ans := (H - sumP + (mxA - 1)) / mxA

	fmt.Println(ans + p)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define ip pair<ll,ll>
#define ff first
#define ss second
#define MAX 100005
const ll MOD = 1000000007;

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

	ll n,d;
	cin>>n>>d;
	int cnt = 0;
	ll p = d*d;
	for(int i=0;i<n;i++){
		ll x,y;
		cin>>x>>y;
		ll r = x*x+y*y;
		if(r <= p)
			++cnt;
	}
	cout<<cnt<<"\n";
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <math.h>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <numeric>
#include <list>
#include <deque>
#include <map>
#include <set>

using namespace std;

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), rend()
#define PB pushback
#define SORT(c) sort((c).begin(),(c).end())

const LL INF = 1LL << 60;

//priority_queue<int> p;

int i, j, k, cnt, N, K, sum;
double ans, tmp, probability;
string s;

//scanf("%d",&N);

//printf("%d", ans);

//cout <<  << endl;


int main(void) {
	scanf("%d %d", &N, &K);
	FOR(i, 1, N + 1) {
		probability = (double)1 / N;
		sum = i;
		while (sum < K) {
			probability *= (double)1 / 2;
			sum *= 2;
		}
		ans += probability;
	}

	printf("%.16f", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

int main()
{
    ll h, w;
    cin >> h >> w;
    if (min(h, w) == 1)
    {
        cout << 1 << endl;
    }
    else
    {
        cout << (h * w + 1) / 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.array, std.conv;

int[] factors(int n) {
    int[] result;
    while (n % 2 == 0) {
        result ~= 2;
        n /= 2;
    }
    for (int i = 3; i * i <= n; i += 2) {
        while (n % i == 0) {
            result ~= i;
            n /= i;
        }
    }
    if (n != 1) result ~= n;
    return result[];
}

void main() {
    int n = readln.chomp.to!int;
    int[] a = factors(n);
    write(n, ":");
    foreach (x; a) {
        write(" ", x);
    }
    writeln;
}


Measured memory_bytes: 2488
using System;
using System.Collections.Generic;

public class CSharp
{
    public static void Main()
    {
        Kyopuro chokudai = new Kyopuro();
        chokudai.AtCoder();
    }
}

public class Kyopuro
{

    int n;
    int[] a;

    public void AtCoder()
    {
        string[] input;
        input = Console.ReadLine().Split(' ');
        n = int.Parse(input[0]);
        a = new int[n];
        input = Console.ReadLine().Split(' ');
        for(int i=0; i<n; i++)
        {
            a[i] = int.Parse(input[i]);
        }
        int y = 0;
        int sign = 1;
        for(int i=0; i<n; i++)
        {
            y += a[i] * sign;
            sign *= -1;
        }
        int[] x = new int[n];
        x[0] = y;

        for (int i=0; i<n-1; i++)
        {
            x[i+1] = a[i] * 2 - x[i];
        }

        for(int i=0; i<n; i++) Console.Write(x[i]+" ");
        Console.WriteLine();
    }
    public static void DebugWL(object x) { System.Diagnostics.Debug.WriteLine(x); }
}

Measured memory_bytes: 27092
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vvin=vector<vin>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){cout<<fixed<<setprecision(20);
		   long double w,h;
           cin>>w>>h;
           cout<<w*h/2<<endl;
           long double x,y;cin>>x>>y;
           if(w==2*x&&h==2*y)cout<<1<<endl;
           else cout<<0<<endl;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
class Graph
{
	int n;
	list<int> *edj;
public:
	Graph(int v)
	{
		this->n = v;
		edj = new list<int> [n];
	}
	void addEdge(int u,int v)
	{
		edj[u].push_back(v);
	}
	void dfs(int src,vector<int> &vis,vector<int> &indeg,vector<int> &dist)
	{
		vis[src] = true;
		for(auto it = edj[src].begin();it != edj[src].end();++it)
		{
			dist[*it] = max(dist[*it],dist[src] + 1);
			indeg[*it]--;
			if(indeg[*it] == 0)
			{
				dfs(*it,vis,indeg,dist);
			}
		}
	}

};

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

	int m;
	cin >> m;

	Graph g(n+1);


	vector<int>vis(n+1,0);
	vector<int>dist(n+1,0);
	vector<int>indeg(n+1,0);

	for(int i = 0;i < m;i++)
	{
		int u;
		int v;
		cin >> u;
		cin >> v;
		g.addEdge(u,v);
		indeg[v]++;
	}

	for(int i = 1;i <= n;i++)
	{
		if(!vis[i] && indeg[i] == 0)
			g.dfs(i,vis,indeg,dist);
	}

	int ans = INT_MIN;
	
	for(int i = 1;i < dist.size();i++)
		ans = max(ans,dist[i]);

	cout << ans;
	return 0;
}

Measured memory_bytes: 9088
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

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

  for(ll i=1;i<=3500;i++){
    for(ll j=i;j<=3500;j++){
      if(N*i+N*j-4*i*j<0){
        if((N*i*j)%abs(N*i+N*j-4*i*j)==0){
          cout<<i<<" "<<j<<" "<<(N*i*j)/abs(N*i+N*j-4*i*j)<<endl;
          return 0;
        }
      }
    }
  }

  return 0;
}


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

bool sub(int n) {
  if (n % 2 == 0) return false;
  int cnt = 0;
  for (int i = 1; i <= n; ++i) {
    if (n % i == 0) ++cnt;
  }
  return cnt == 8;
}

int main() {
  int n;
  cin >> n;
  
  int cnt = 0;
  for (int i = 1; i <= n; ++i) {
    cnt += sub(i);
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
import Data.List

main = do
  s <- getLine
  let ans = compute s
  print ans

{-
>>> 下りは底から 3 2 1 0 と
<<< 上りも底から 0 1 2 3 とカウントしていく、
底は必ず0
問題は山の方で、>>><<<< 大きい方を選択する必要がある
-}

compute :: String -> Int
compute s = loop 0 $ map f $ group $ map ('<' ==) s
  where
    f as = (if head as then Right else Left) (length as)
    t n = n * (n-1) `div` 2
    loop acc (Right a : Left b : es) = loop (acc + t a + t b + max a b) es
    loop 0 (Left a : es) = loop (t (succ a)) es
    loop acc (Right a : []) = acc + t (succ a)
    loop acc [] = acc


Measured memory_bytes: 32124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	for (auto& x : A) cin >> x;
	sort(A.begin(), A.end());
	int r = 0;
	for (int i = 0; i < K; ++ i) r += A[i];
	cout << r << endl;
}


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

using namespace std;

typedef pair <int,int>	PII;
typedef vector <int>	VI;
typedef vector <PII>    VII;

const int MD=998244353;
const int INF = 1e7+9;

const int N=1e5+33;

int n,k,h,w;


int main() {
	ios_base::sync_with_stdio(false);cout.tie(nullptr);cin.tie(nullptr);
	cin>>n>>h>>w;
    int ans=0;
    while(n--){
        int a,b;
        cin>>a>>b;
        if(h<=a && b>=w)ans++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256