akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <map>
#include <iostream>
#include <iterator>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <vector>
// #include <bits/stdc++.h>
using namespace std;

// #define ls now << 1
// #define rs now << 1 | 1
#define PB push_back
// #define MP make_pair
// #define double long double
#define int long long
// #define us unsigned
// #define LL long long
const int N = 1000000;
// const int M = 125000;
// #define re register
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
// const double inf_double = 1e4;
// const double eps = 1e-4;
// inline char nc()
// {
//     static char buf[1000000], *p1 = buf, *p2 = buf;
//     return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2) ? EOF : *p1++;
// }
// #define getchar nc
inline int read()
{
    register int s = 0;
    register bool neg = 0;
    register char c = getchar();
    for (; c < '0' || c > '9'; c = getchar())
        neg |= (c == '-');
    for (; c >= '0' && c <= '9'; s = s * 10 + (c ^ 48), c = getchar())
        ;
    return (neg ? -s : s);
}

int a, s[N + 10], prime[N + 10], mu[N + 10], top, f[N + 10], mx, ans;
bool vis[N + 10];

inline void init()
{
    mu[1] = 1;
    for (int i = 2; i <= N; i++)
    {
        if (!vis[i])
        {
            prime[++top] = i;
            mu[i] = -1;
        }
        for (int j = 1; j <= top && i * prime[j] <= N; j++)
        {
            vis[i * prime[j]] = 1;
            if (i % prime[j] == 0)
                break;
            mu[i * prime[j]] = -mu[i];
        }
    }
    for (int i = 1; i <= N; i++)
        for (int j = i; j <= N; j += i)
            f[j] = (f[j] + i * mu[i] + mod) % mod;
}

inline int qpow(int n, int m)
{
    int k = 1;
    while (m)
    {
        if (m & 1)
            k = k * n % mod;
        n = n * n % mod;
        m >>= 1;
    }
    return k;
}

signed main()
{
    init();
    a = read();
    int x;
    for (int i = 1; i <= a; i++)
    {
        x = read();
        ans = (ans - x + mod) % mod;
        s[x]++;
        mx = max(mx, x);
    }
    for (int i = 1; i <= mx; i++)
    {
        int sum = 0;
        for (int j = 1; j <= mx / i; j++)
            sum = (sum + 1ll * j * s[i * j]) % mod;
        sum = sum * sum % mod * i % mod * f[i] % mod;
        ans = (ans + sum) % mod;
    }
    printf("%lld", ans * qpow(2, mod - 2) % mod);
    return 0;
}

Measured memory_bytes: 28700
#include <stdio.h>

int	main(void)
{
  	int	N;
  	int	num;
  	int i;
  	int ans;
  
  	num = scanf("%d", &N);
  	if (num != 1)
      	return (0);
  
  	for (i=1; i<10; i++)
    {
      	if (N % i == 0)
        {
      		ans = N / i;
          	if (ans > 9)
            {
              	continue ;
            }
          	else
            {
              	printf("Yes");
              	return (0);
            }
        }
    }
  	printf("No");
  	return (0);
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	map<string,int>m;;
	for(int i=0;i<n;++i){
		string s; cin>>s;
		++m[s];
	}
	int mx=0;
	for(auto&i:m)mx=max(mx,i.second);
	for(auto&i:m)if(i.second==mx)cout<<i.first<<"\n"s;
}

Measured memory_bytes: 23808
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(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 (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll h,n;cin >> h >>n;
    vl at(n),mp(n);
    rep(i,n)cin >> at[i] >> mp[i];
    vvl dp(n+1,vl(h+1,inf));
    rep(i,n+1)dp[i][0]=0;
    rep(i,n){
        rep(sumat,h+1){
            chmin(dp[i+1][sumat],dp[i][sumat]);
            chmin(dp[i+1][min(sumat+at[i],h)],dp[i+1][sumat]+mp[i]);
        }
    }

    cout << dp[n][h] <<endl;
}

Measured memory_bytes: 78592
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+5;
map<ll,int>mp;
ll sum[N],x[N],m,n,ans,dp[N];
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>x[i],dp[i]=dp[i-1]+x[i];
	for(int i=0;i<=n;i++)
	{
		if(i>=m)mp[dp[i-m]]--;
		dp[i]=(dp[i]+m-i%m)%m;
		ans+=mp[dp[i]];
		mp[dp[i]]++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 16896
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>
#include <math.h>

using namespace std;

int main() {
  int n,d,A[20][20],num = 0;
  cin >> n >> d;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < d; j++)
      cin >> A[i][j];
  }
  
  for(int i = 0; i <= n-2; i++) {
    int sum = 0;
    for(int j = i+1; j <= n-1; j++) {
      sum = 0;
      for(int k = 0; k < d; k++) {
        sum += (A[i][k]-A[j][k])*(A[i][k]-A[j][k]);
      }
      double dist = sqrt(sum);
      if(dist == (int)dist) num++;
    }
  }
  cout << num << endl;
}

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

int main() {

 int N,K,M;
  cin >>N>>K;
  M=1;
 
    int i=0;
    while (M <= N) {
    M*=K;
//    cout<<M<<endl;
    i++;
  }
  cout<<i<<endl;
  

}


Measured memory_bytes: 256
#include<iostream>
using std::string;
using std::cin;
using std::cout;
const string n="keyence";
int main() {
    string s;cin>>s;
    int len=s.length();
    bool f=false;
    for(int i=0;i<=7&&!f;i++) {
        string tmp=s.substr(0,i);
        tmp+=s.substr(len-7+i,7-i);
        if(tmp==n) f=1;
    }
    cout<<(f?"YES":"NO");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
constexpr int V = 500;
constexpr int INF = 1000000000;
typedef int Weight;
struct Edge{
  	int src, dest;
  	int cap, rev;
  	Weight weight;
  	bool operator < (const Edge &rhs) const {return weight > rhs.weight;}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

//FordFulkerson(O(F|E|))-----------------------------------------------------------
//???????????°|V|?????????
bool add_edge_impl(Graph &g, int src, int dest) {
  for (size_t i = 0; i < g[src].size(); ++i) {
    if (g[src][i].dest == dest) {
      g[src][i].weight = 0;
      return true;
    }
  }
  return false;
}

void add_edge(Graph &g, int src, int dest) {
  if (!add_edge_impl(g, src, dest)) {
    g[src].push_back((Edge){src, dest, 1, (int)g[dest].size(), 0});
    g[dest].push_back((Edge){dest, src, 1, (int)g[src].size() - 1, 0});
  } else {
    add_edge_impl(g, dest, src);
  }
}

void remove_edge_impl(Graph &g, int src, int dest) {
  for (size_t i = 0; i < g[src].size(); ++i) {
    if (g[src][i].dest == dest) g[src][i].weight = 1;
  }
}

void remove_edge(Graph &g, int src, int dest) {
  remove_edge_impl(g, src, dest);
  remove_edge_impl(g, dest, src);
}

bool visited[V];
int dfs(Graph &g, int v, int t, int f) {
	if (v == t) return f;
	visited[v] = true;
	REP(i, g[v].size()) {
		Edge& e = g[v][i];
    if (e.weight == 1) continue;
		if (!visited[e.dest] && e.cap > 0) {
			int d = dfs(g, e.dest, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				g[e.dest][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(Graph &g, int s, int t) {
	int flow = 0;
	for(;;) {
		memset(visited, 0, sizeof(visited));
		int f = dfs(g, s, t, INF);
		if (f == 0) return flow;
		flow += f;
	}
}


int main() {
  int n,e,q;
  cin>>n>>e>>q;
  Graph g(V);
  REP(i,e) {
    int f,t;
    cin>>f>>t;
    --f;--t;
    add_edge(g, f, t);
  }
  int flow = 0;
  REP(i,q) {
    int m, a, b;
    cin>>m>>a>>b;
    --a;--b;
    if (m==1) {
      add_edge(g, a, b);
      flow += max_flow(g, 0, n-1);
      cout << flow << endl;
    } else {
      remove_edge(g, a, b);
      REP(j,n) {
        for (auto& e:g[j]) e.cap = 1;
      }
      flow = max_flow(g, 0, n-1);
      cout << flow << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 4188
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;

int main(){

    int N, M;
    vector<pair<int, int>> combat;
    cin >> N >> M;
    combat.resize(M);
    for (int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;
        combat[i] = make_pair(a - 1, b - 1);
    }

    sort(combat.begin(), combat.end(), [](const pair<int, int> &a, const pair<int, int> &b) { return a.second < b.second; });

    int ans = 1;
    int end = combat[0].second;
    for (int i = 1; i < M; i++){
        if(combat[i].first >= end){
            ans++;
            end = combat[i].second;
        }
    }
        cout << ans << endl;
}

Measured memory_bytes: 1152
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt(),m = sc.nextInt();
		int a[]=new int[n];
		for(int i=0; i<n; i++) {
			a[i]=sc.nextInt();
		}
		int min=-1;
		for(int i=0; i<n; i++) {
			if(min==-1||a[i]<min)min=a[i];
		}
		int nomin=0;
		for(int i=0; i<n; i++) {
			if(a[i]==min)nomin++;
		}
		int kai=(int)Math.ceil((n-nomin)*1.0/(m-1));
		System.out.println(kai);
	}
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using db = double;
using ii = pair <int, int>;

#define int long long
#define FOR(a, b, c) for(int a = b, _c = c; a <= _c; ++a)
#define FORD(a, b, c) for(int a = b, _c = c; a >= _c; --a)
#define REP(a, b, c) for(int a = b, _ = c; a < _; ++a)
#define ALL(a, b) for(auto &a : b)
#define pb push_back
#define mp make_pair
#define all(a) begin(a), end(a)
#define reset(f, x) memset(f, x, sizeof(f))
#define fi first
#define se second
#define bit(x, i) (x >> (i - 1) & 1ll)
#define onbit(x, i) (x | (1ll << (i - 1)))
#define offbit(x, i) (x & ~(1ll << (i - 1)))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll

template <class T> void Max(T &x, T y) { x = (x > y) ? x : y;}

const int N = 5005;
int n;
double a[N], f[N][N];

main() {
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n;
  FOR(i, 1, n) cin >> a[i];
  f[0][0] = 1.0;
  FOR(i, 1, n) {
    FOR(j, 0, n) {
      f[i][j + 1] += f[i - 1][j] * a[i];
      f[i][j] += f[i - 1][j] * (1.0 - a[i]);
    }
  }
  db tot = 0.0;
  FOR(i, (n + 1) / 2, n) tot += f[n][i];
  cout << setprecision(12) << fixed;
  cout << tot;
}


Measured memory_bytes: 118400
n, k = map(int, input().split())
l = list(map(int, input().split()))
ans = 9999999999999
for i in range(len(l) - k + 1):
    min_l = min(0, l[i])
    max_l = max(0, l[i+k-1])
    min_abs = min(abs(min_l), abs(max_l))
    max_abs = max(abs(min_l), abs(max_l))
    ans = min(ans, min_abs * 2 + max_abs)
print(ans)

Measured memory_bytes: 14384
#include<stdio.h>

int main()
{
  int n1;
  int n2;
  int temp;
  int count = 0;
  while(1)
    {
      scanf("%d %d", &n1, &n2);
      count = 0;
      if(n1 == 0 && n2 == 0)
	{
	  break;
	}
      for(int i = 1; i <= n1; i++)
	{
	  for(int j = 1; j <=n1; j++)
	    {
	      for(int k = 1; k<=n1; k++)
		{
		  if(i == j || j == k || i == k)
		    {
		    }
		  else
		    {
		      temp = i+j+k;
		      if(temp == n2)
			{
			  count++;
			}
		    }
		}
	    }
	}
      printf("%d\n", count/6);
    }
}



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

int main() {
  int N;
  cin >> N;
  string S;
  
  for(int i=0; i<N; i++) {
    cin >> S;
    if(S == "Y") {
      cout << "Four" << endl;
      break;
    }
  }
  
  if(S != "Y") {
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false

signed main(void){
    int N;
    string S;
    int R=0,G=0,B=0;
    cin >> N;
    cin >> S;
    int Ans=0;
    REP(i,N){
        if(S[i]=='R'){
            R++;
        }else if(S[i]=='G'){
            G++;
        }else{
            B++;
        }
    }
    Ans+=R*G*B;
    REP(i,N){
        if(S[i]!='R')continue;
        REP(j,N){
            if(S[j]!='G')continue;
            
            int m = i+j;
            if(m%2==0 && S[m/2]=='B'){
                Ans--;
            }
            
            m = 2*i-j;
            if(0<=m && m<N && S[m]=='B'){
                Ans--;
            }
            
            m = 2*j-i;
            if(0<=m && m<N && S[m]=='B'){
                Ans--;
            }
        }
    }
    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 3636
#!/usr/bin/env python3
import sys
import math


def solve(H: int, W: int):
    if H == 1 or W == 1:
        print(1)
        return
    ans = math.ceil(H / 2) * math.ceil(W / 2) + (H // 2) * (W // 2)
    return print(ans)


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    solve(H, W)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61760
n = int(input())
a = list(map(int,input().split()))

ans = [0] * (n+1)
d = dict()
for i,ai in enumerate(a,1):
    if(ai in d):
        d[ai][1] += 1
    else:
        d[ai] = [i,1]
d[0] = [0,0]

a_unique = list(set(a))
a_unique.sort(reverse=True)
a_unique.append(0)

for i in range(len(a_unique)-1):
    num = a_unique[i]
    next = a_unique[i+1]
    head = d[num][0]
    ans[head] += (num-next) * d[num][1]

    d[next][0] = min(d[next][0],d[num][0])
    d[next][1] += d[num][1]

print('\n'.join(map(str,ans[1:])))

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

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main() {
  int N, K;
  cin >> N >> K;
  combination c(3000);  // 二項係数ライブラリを初期化

  // 求める
  for (int k = 1; k <= K; ++k)
    // blue * red

    cout << c(K - 1, k - 1).x * c(N - K + 1, k).x % mod << endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc137/tasks/abc137_c
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

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

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

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

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

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

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

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

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

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: usize, s: [chars; n]
    };
    let mut s = s;
    let mut s = s.into_iter().map(|mut si| { si.sort(); si }).collect::<Vec<_>>();
    s.sort();

    let mut ans = 0;
    let mut i = 0;
    while i < n {
        let mut j = i;
        while j < n && s[i] == s[j] {
            j += 1;
        }
        ans += (j-i)*(j-i-1)/2;
        i = j;
    }
    println!("{}", ans);
}


Measured memory_bytes: 20732
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
    	a:usize,
        b:usize,
        c:usize
    }
    println!("{}", if a+b+c >= 22 { "bust" } else { "win" });
}

Measured memory_bytes: 4352
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int l[m],r[m],a1=0,a2=n;
	for(int cnt=0;cnt<m;cnt++){
		cin>>l[cnt]>>r[cnt];
		a1=max(a1,l[cnt]);
		a2=min(a2,r[cnt]);
	}
	if(a2-a1<0)cout<<0;
	else cout<<a2-a1+1;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int N=sc.nextInt();
			int a, b;
			int[] d=new int[100010];
			for(int i=0; i<N; i++) {
				a=sc.nextInt();
				b=sc.nextInt();
				for(int j=a-1; j<=b-1; j++) {
					d[j]++;
				}
			}
			int ans=0;
			for(int i=0; i<=100001; i++) {
				if(i<=d[i]) {
					ans=i;
				}
			}
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 69472
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = Long.parseLong(sc.next());
    long d = 0;
    long min = Long.MAX_VALUE;
    long ans = 0;
    
    for (long i=1; i<1000001; i++) {
      if(n%i == 0) {
        d = n/i;
        ans = d + i - 2;
        if(ans<min) {
          min = ans;
        }
      }
      if(n==i){
        break;
      }
    }
    
    System.out.println(min);
  }
}


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


def main():
    S = input().rstrip()
    Q = int(input())
    reverse_flag = False
    head = ''
    tail = ''
    for _ in range(Q):
        q = input().rstrip()
        if q == '1':
            reverse_flag = not reverse_flag
        else:
            _, F, C = q.split()
            if (F == '1' and reverse_flag is False) or (F == '2' and reverse_flag is True):
                head += C
            else:
                tail += C
    if reverse_flag is True:
        print(tail[::-1] + S[::-1] + head)
    else:
        print(head[::-1] + S + tail)


if __name__ == '__main__':
    main()


Measured memory_bytes: 222152
#include<bits/stdc++.h>
using namespace std;
const int N(111111);
typedef long long LL;
LL s[N];
int modulo(1e9 + 7);
LL inf(2e18);
int c[2][N], dp[2][N], inc[2][N];
int main() {
	int n;
	LL a[2];
	cin >> n >> a[0] >> a[1];
	s[0] = -inf;
	s[n + 1] = inf;
	for(int i(1); i <= n; i++) {
		cin >> s[i];
		for(int d(0); d < 2; d++) {
			c[d][i] = c[d][i - 1] + (s[i] - s[i - 1] >= a[d]);
		}
	}
	dp[0][1] = 1;
	int nxt[2] = {1, 1};
	for(int i(1); i <= n + 1; i++) {
		for(int d(0); d < 2; d++) {
			if(s[i] - s[i - 1] >= a[d ^ 1])
				dp[d][i + 1] = (dp[d][i + 1] + dp[d][i]) % modulo;
			nxt[d] = max(nxt[d], i + 1);
			while(nxt[d] <= n && s[nxt[d]] - s[i - 1] < a[d])
				nxt[d]++;
		}
		for(int d(0); d < 2; d++) {
			if(c[d][nxt[d ^ 1] - 1] - c[d][i] == nxt[d ^ 1] - 1 - i)
				dp[d ^ 1][nxt[d ^ 1]] = (dp[d ^ 1][nxt[d ^ 1]] + dp[d][i]) % modulo;
		}
	}
	cout << (dp[0][n + 1] + dp[1][n + 1]) % modulo << endl;
}


Measured memory_bytes: 2688
#include <iostream>
using namespace std;
 
int main() {
  int H, N;
  cin >> H >> N;
  int all = 0;
  for (int i = 0; i < N;i++) {
    int A;
    cin >> A;
    all += A;
  }
  if (H <= all) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())[:-1]
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [list(input())[:-1] for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
T = list(input())[:-1]
n = len(T)
for i in range(n):
    if T[i] == "?":
        T[i] = "D"
print("".join(T))

Measured memory_bytes: 13360
use std::io;
use std::str::FromStr;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();
    let mut it = buf.split_whitespace().map(|n| usize::from_str(n).unwrap());
    let (a, b, x) = (it.next().unwrap(), it.next().unwrap(), it.next().unwrap());

    if a <= x && x <= a + b {
        println!("YES");
    } else {
        println!("NO");
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <set>
#include <bitset>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

string min2(string a, string b) {
  if (a.empty()) return b;
  if (a.size()>b.size()) return b;
  if (a.size()==b.size() && a>b) return b;
  return a;
}

int main() {
  int n;
  while(cin >> n, n) {
    string s[n];
    REP(i,n) {
      cin >> s[i];
    }

    string dp[1<<n][n];
    REP(i,n)
      dp[1<<i][i] = s[i];
    REP(S, 1<<n) {
//      cout << bitset<5>(S) << endl;
      REP(i,n) if (S>>i&1) {
          // cout << i << " ";
          // cout << dp[S][i] << endl;
        REP(j,n) if (!(S>>j&1)) {
          string tmp = dp[S][i];
          if (tmp.find(s[j]) != tmp.npos) {
            dp[S|1<<j][j] = min2(dp[S|1<<j][j],dp[S][i]);
            continue;
          }
          bool f = 0;
          for (int k=min(s[j].size()-1, tmp.size());k>=1; --k) { // tmp ツづ個前ツ陛サツつェツ暗ェツ致
            if (s[j].substr(s[j].size()-k, k) == tmp.substr(0, k)) {
              dp[S|1<<j][j] = min2(dp[S|1<<j][j],s[j].substr(0, s[j].size()-k) + tmp);
              f = 1;
              break;
            }
          }
          for (int k=min(s[j].size()-1, tmp.size());k>=1; --k) { // tmp ツづ個古」ツ陛サツつェツ暗ェツ致
            if (s[j].substr(0, k) == tmp.substr(tmp.size()-k, k)) {
              dp[S|1<<j][j] = min2(dp[S|1<<j][j],tmp + s[j].substr(k));
              f = 1;
              break;
            }
          }
          if (!f) {
            dp[S|1<<j][j] = min2(dp[S|1<<j][j],min(tmp+s[j], s[j]+tmp));
          }
        }
      }
    }
    string res;

    REP(i,n)
      res = min2(res, dp[(1<<n)-1][i]);
    cout << res << endl;
  }
}

Measured memory_bytes: 1284
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=805;
//i_am_noob
int a,b,c;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> a >> b >> c;
	print1(c/a*b);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
#define loop(n) for(int i=0; i<n; i++)
#define rep(i,start,n) for(int i=start; i<n; i++)

void solve(){
	string s;cin >> s;
	int n = s.length()+1;

	vector<int> a(n);

	rep(i,0,n-1)
	if(s[i] == '<') a[i+1] = max(a[i+1], a[i]+1);

	for(int i = n-1; i >=0; i--)
	if(s[i] == '>') a[i] = max(a[i], a[i+1]+1);

	int ans = 0;
	for(auto i : a)ans += i;
	cout << ans << endl;
}
	
signed main(){
    fast;    
    // int t;cin>>t;while(t--)
    solve();    
    return 0;
}


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

int main()
{
    int n;
    cin>>n;
    if(n<=81)
    {
        for(int i = 1; i<10 ; i++)
        {
            int a = n/i;
            int b = n%i;
            if(a<10 && b==0)
            {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;

    return 0;

}


Measured memory_bytes: 256
from math import sin, cos, radians, sqrt, pi

a, b, h, m = map(int, input().split())


th = m/60 * 2*pi
tm = (60*h + m)/720 * 2*pi
xh = a*cos(th)
yh = a*sin(th)
xm = b*cos(tm)
ym = b*sin(tm)
dx = xh-xm
dy = yh-ym
ans = sqrt(dx*dx + dy*dy)
print(ans)


Measured memory_bytes: 9576
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

string s;

int main(int argc, char **argv) {
	cin >> s;
	if (s.length() == 2 && s[0] == s[1]) {
		cout << "1 2" << endl;
		return 0;
	}
	int res = -1;
	REP(i, s.length() - 3) {
		if (s[i] == s[i + 1] || s[i] == s[i + 2] || s[i + 1] == s[i + 2]) {
			res = i;
			break;
		}
	}
	if (res == -1) cout << "-1 -1" << endl;
	else cout << (res + 1) << " " << (res + 3) << endl;
	return 0;
}


Measured memory_bytes: 512
a,b,k=map(int,input().split())
c=set()
for i in range(min(k,b-a+1)):
    c.add(i+a)
for i in range(min(k,b-a+1)):
    c.add(b-i)
c=sorted(c)
c=list(map(int,c))
for i in c:
    print(i)


Measured memory_bytes: 3060
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	cout << (n - 1)*(m - 1) << endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

int main( int argc, char *argv[] ) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	string a, b, c;
	cin >> a >> b >> c;

	cout << char(toupper(a[0])) << char(toupper(b[0])) << char(toupper(c[0])) << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

class UnionFind
{
public:
    ll n;
    lvector uf;
    UnionFind(ll N);
    //~UnionFind();
    ll find(ll x);
    ll size(ll x) {return -(*this).uf[(*this).find(x)];}
    void unite(ll x, ll y);
};

UnionFind::UnionFind(ll N)
{
  (*this).n=N;
  rep(i,n) (*this).uf.emplace_back(-1);
}

ll UnionFind::find(ll x)
{
  if((*this).uf[x]<0) return x;
  (*this).uf[x]=(*this).find((*this).uf[x]);
  return (*this).uf[x];
}

void UnionFind::unite(ll x, ll y)
{
  x=(*this).find(x);
  y=(*this).find(y);
  if(x==y) return;
  if((*this).size(x)>(*this).size(y)) swap(x,y);
  (*this).uf[y]+=(*this).uf[x];
  (*this).uf[x]=y;
  (*this).n-=1;
  return;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m,a,b;cin>>n>>m;
  lvector ans(m,0);ans[0]+=n*(n-1)/2;
  UnionFind U(n);
  vector<P> pvec(m);
  rep(i,m) {cin>>a>>b;pvec[m-1-i]=P(a,b);}
  for(ll i=0;i<m-1;++i) {
    a=pvec[i].first-1,b=pvec[i].second-1;
    if(U.find(a)==U.find(b)) ans[i+1]=ans[i];
    else ans[i+1]=ans[i]-U.size(a)*U.size(b);
    U.unite(a,b);
  }
  reverse(ALL(ans));
  for(ll i:ans) print(i);
  return 0;
}

Measured memory_bytes: 4596
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		
		Scanner sc=new Scanner(System.in);
		
		String str=sc.next();
		String[] st=new String[str.length()];
		
		if(str.length()%2==0) {
			
			for(int i=0;i<str.length();i++) {
				st[i]=String.valueOf(str.charAt(i));
			}
			
			Arrays.sort(st);
			
			int ans=0;
			
			for(int i=0;i<str.length()/2;i++) {
				
				if(st[2*i].equals(st[2*i+1])){
					ans+=0;
				}else{
					ans+=1;
				}
			}
			
			if(ans==0) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
			
		}else {
			
			System.out.println("No");
			
		}
		
		sc.close();
	}
}

Measured memory_bytes: 21844
//#pragma comment (linker, "/STACK:256000000")
#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(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define ms(a,v) memset(a,v,sizeof(a))
#define mp make_pair
#define write(x) cout<<(x)<<endl
using namespace std; typedef long long ll;
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; }
const int INF = 1 << 28; const ll LINF = 1ll << 60;
const int MAX = 1e5 + 5; const int MOD = 1e9 + 7; const double EPS = 1e-6;
const int dy[4] = { 0,1,0,-1 }; const int dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int N;
vector<pair<int, int>> red, blue;
int ans = 0;

int main() {
    cin >> N;
    red.reserve(N); blue.reserve(N);
    rep(i, N) {
        int a, b; cin >> a >> b;
        red.emplace_back(a, b);
    }
    rep(i, N) {
        int a, b; cin >> a >> b;
        blue.emplace_back(a, b);
    }
    sort(all(red)); sort(all(blue));

    vector<bool> paired(N);
    for (int b = 0; b < N; ++b) {
        
        int imax = -1;
        for (int i = 0; i < N; ++i) {
            if (red[i].first >= blue[b].first) break;
            if (!paired[i] && red[i].second < blue[b].second) {
                if (imax != -1 && red[i].second > red[imax].second) imax = i;
                else if (imax == -1) imax = i;
            } 
        }

        if (imax != -1) {
            paired[imax] = true;
        }
    }

    ans = count(all(paired), true);
    write(ans);
}

Measured memory_bytes: 256
#include<iostream>
 
using namespace std;
 
int main(){
    int a,N,ans=0;
    string S;
    cin >> S;
    if(S == "Sunny") cout << "Cloudy" << endl;
    else if(S == "Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
}


Measured memory_bytes: 256
# coding: utf-8
# Here your code !

i = int(input().rstrip())
point = []
k = 0
while i :
    point.append([0, 0])
    for j in range(i):
        l = list(map(int, input().rstrip().split()))
        if l[0] > l[1]:
            point[k][0] += l[0] + l[1]
        elif l[0] < l[1]:
            point[k][1] += l[0] + l[1]
        else:
            point[k][0] += l[0]
            point[k][1] += l[1]
    i = int(input().rstrip())
    k += 1
for i in range(k):
    print(point[i][0],point[i][1])

Measured memory_bytes: 7656
#include<iostream>
using namespace std;
typedef long long int ll;
main()
{
  int n;cin>>n;ll a[n];bool f=1;int sum=0;
  for(int i=0;i<n;i++){cin>>a[i];if(a[i]&1)f=0;}
  if(f)
  {
    while(true)
    {
      for(int i=0;i<n;i++)
      {
        a[i]/=2;if(a[i]&1){f=0;break;}
      }
      sum++;
      if(!f)break;
    }
    cout<<sum;
  }
  else cout<<0;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
using ull = unsigned long long;
const auto INF = (ull)1e20;
using namespace std;
int main(){
    ull n;
    cin >> n;
    auto f = [](ull a,ull b){
        auto t = max(a,b);
        return (ull)log10(t)+1;
    };
    ull _min = INF;
    for(ull i=1;i<=n/i;i++){
        if(n%i==0){
            _min = min(_min,f(i,n/i));
        }
    }
    cout << _min;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstring>
#include <cstdio>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define fst first
#define snd second
#define MP make_pair //incase c++11 or later is not available

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
#define LIM_INF (INT_MAX)
//const int INF = INT_MAX/3;
#define PI = 3.14159265358979323846
/*------------------------------------------------------------------------------*/

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

  ll lb = 0, ub = X;

  while(ub - lb > 1){
    ll mid = (ub + lb) / 2;
    if((mid + 1) * mid / 2 >= X){
      ub = mid;
    } else {
      lb = mid;
    }
  }

  cout << ub << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct node{
	int xx,yy,hh;
};
bool cmp(node a,node b)
{
	if(a.hh>b.hh) return true;
	else return false;
}
int main()
{
	int n;
	cin>>n;
	node f[n];
	for(int i=0;i<n;i++) cin>>f[i].xx>>f[i].yy>>f[i].hh;
	stable_sort(f,f+n,cmp);
	for(int i=0;i<=100;i++)
	for(int j=0;j<=100;j++)
	{
		bool check=true;
		int h=f[0].hh+abs(f[0].xx-i)+abs(f[0].yy-j);
		for(int k=1;k<n;k++)
		if(max(h-abs(f[k].xx-i)-abs(f[k].yy-j),0)!=f[k].hh) check=false;
		if(check) {cout<<i<<" "<<j<<" "<<h;return 0;}
	}
}

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

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  for(int i = 0; i < N; i++){
    cin >> H.at(i);
  }
  for(int i = N-1; i > 0; i--){
    if(H.at(i) < H.at(i-1)) {
      if(H.at(i-1) - H.at(i) > 1) {
        cout << "No";
        return 0;
      }
      H.at(i-1) += -1;
    }
  }
  cout << "Yes";
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <ios>
#include <iomanip>
#define rep(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<double> p(N);
  rep(i, 0, N) cin >> p[i];
  
  vector<vector<double>> dp(N + 1, vector<double>(N + 1, 0));
  dp[0][0] = 1;
  rep(i, 1, N + 1) {
    dp[i][0] = dp[i - 1][0] * (1 - p[i - 1]);
    rep(j, 1, i + 1) {
      dp[i][j] = dp[i - 1][j - 1] * p[i - 1] + dp[i - 1][j] * (1 - p[i - 1]);
    }
  }
  
  double ans = 0;
  rep(i, 0, N + 1) {
    if (i > (N - i)) ans += dp[N][i];
  }
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ss second
#define ff first
#define pb push_back
#define mp make_pair

int main(){
    ios_base::sync_with_stdio(0);
    string x[7]={"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    string a;
    cin>>a;
    for(int i=0;i<7;i++){
        if(a==x[i]){
            cout<<7-i;
            return 0;
        }
    }
    return 0;
    }


Measured memory_bytes: 256
B = [False]*100005
C = [0]*100005
for i in range(2,100001):
    if not B[i]:
      	for j in range(i+i,100001,i):
          	B[j]=True
for i in range(3,100001,2):
    if not B[i] and not B[(i+1)//2]:
        C[i]+=1
for i in range(3,100001):
    C[i]=C[i]+C[i-1]
    
N = int(input())
for _ in range(N):
    a, b = map(int,input().split())
    print(C[b]-C[a-1])


Measured memory_bytes: 12440
/*input
18
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
*/
#include <bits/stdc++.h>
using namespace std;
int64_t n,ans;
string s;
map<pair<string,string>,int> l[19];
int main(){
	cin>>n>>s;
	for(int mask=0;mask<(1<<n);++mask){
		string red="",blue="";
		int num = __builtin_popcount(mask);
		for(int i=0;i<n;++i) 
			if((mask>>i)&1)
				red += s[i];
			else
				blue += s[i];
		reverse(blue.begin(),blue.end());
		++l[num][{red,blue}];
	}
	for(int mask=0;mask<(1<<n);++mask){
		string red="",blue="";
		int num = __builtin_popcount(mask);
		for(int i=0;i<n;++i) 
			if((mask>>i)&1)
				blue += s[2*n-1-i];
			else
				red += s[2*n-1-i];
		reverse(red.begin(),red.end());
		ans += l[num][{blue,red}];
	}
	cout<<ans;
}

Measured memory_bytes: 87040
#include <cstdio>
#include <utility>
#include <cctype>
#include <unordered_map>
using namespace std;

#ifdef __linux
#define _U(s) s##_unlocked
#else
#define _U(s) _##s##_nolock
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
#define gcu _U(getchar)
#define pcu _U(putchar)
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;char c;while(isspace(c = gcu()));do{s+=c;}while(c=gcu(),c!=' '&&c!='\n'&&c!=EOF);return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;while(isspace(c = gcu()));if(c=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H &&h, T... t){out(h);out(t...);}
template <typename... T> _OUTL(T... t){out(t...);outl();}
struct range{
	int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

struct tree {
	int n;
	unordered_map<char, tree *> c;
	~tree () {
		for (auto i: c)
			delete i.second;
	}
	tree * insert(char a) {
		n++;
		if (!c.count(a))
			c[a] = new tree();
		return c[a];
	}
	int min_code (int d) {
		if (n <= 1)
			return d;
		int r {};
		for (auto i: c)
			r = max(r, i.second->min_code(d + 1));
		return r;
	}
};

int main() {
	for (int n; (n = in);) {
		tree *t = new tree();
		outl([&] {
			bool r {true};
			times(i, n) {
				string s = in;
				tree *c {t};
				auto j {s.begin()};
				bool v {true};
				do {
					if (v)
						c = c->insert(*j);
					v = *j == 'a' || *j == 'i' || *j == 'u' || *j == 'e' || *j == 'o';
				} while (++j != s.end());
				if (c->c.count('_'))
					r = false;
				c->insert('_');
			}
			return r ? t->min_code(0) : -1;}());
		delete t;
	}
}


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

using namespace std;

int n, x;
bool flag;

int main()
{
    cin>>n;
    for(int i = 0; i < n; i ++)
    {
        cin>>x;
        if(x % 2 == 0)
        {
            if(x % 3 != 0 && x % 5 != 0)
                flag = 1;
        }
    }
    if(flag)
        cout<<"DENIED";
    else cout<<"APPROVED";
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int max(int i,int j,int l)
{
    int p=0;
    p=p>i?p:i;
    p=p>j?p:j;
    p=p>l?p:l;
    return p;
}
int min(int i,int j)
{
    return i>j?i:j;
}
int main()
{
    int n,m,i,j,k=0;
    char a[3000],b[3000],d[3000];
    scanf("%s %s",&a,&b);
    n=strlen(a);
    m=strlen(b);
    int c[n+1][m+1];
    for(i=0;i<n+1;i++)
        c[i][0]=0;
    for(i=0;i<m+1;i++)
        c[0][i]=0;
    for(i=1;i<n+1;i++)
    {
        for(j=1;j<m+1;j++)
        {
            if(a[i-1]==b[j-1])
                c[i][j]=max(c[i-1][j-1]+1,c[i-1][j],c[i][j-1]);
            else
                c[i][j]=min(c[i-1][j],c[i][j-1]);
        }
    }
    i=n;
    j=m;
    k=0;
    while(1)
    {
        if((i==0)||(j==0))
            break;
        if((a[i-1]==b[j-1])&&(c[i][j]==c[i-1][j-1]+1))
        {
            d[k]=a[i-1];
            k++;
            i--;
            j--;
        }
        else if(c[i][j]==c[i-1][j])
            i--;
        else
            j--;
    }
    k--;
    if(k==-1)
        printf(" ");
    else
    {
        for(i=k;i>=0;i--)
        printf("%c",d[i]);
    }
    return 0;
}


Measured memory_bytes: 36808