akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int mod = 1e9 + 7;
int factorial(int n)
{
	int result = 1;
	for (int i = 2; i <= n; ++i)
	{
		result = result * i;
	}
	return result;
}
int main()
{
	SPEED
	int n;
	cin >> n;
	int x, y;
	vector<pair<int, int>> v;
	
	for (int i = 0; i < n; ++i)
	{
		cin >> x >> y;
		v.pb(mp(x,y));
	}

	int total_paths = factorial(n);

	int no_of_citypair = (n*(n-1))/2;
	int multiplier = (total_paths*(n-1))/no_of_citypair;

	ld avg_dis = 0;
	for (int i = 0; i < n; ++i)
	{
		for (int j = i+1; j < n; ++j)
		{
			ld temp = sqrt(((v[i].fi - v[j].fi)*(v[i].fi - v[j].fi)) + ((v[i].se - v[j].se)*(v[i].se - v[j].se)));
			avg_dis += (multiplier*temp);
		}
	}
	avg_dis = avg_dis/total_paths;
	std::cout << std::fixed << std::showpoint;
    std::cout << std::setprecision(8);
    std::cout << avg_dis;
	return 0;
}

Measured memory_bytes: 256
/* https://atcoder.jp/contests/abc106/tasks/abc106_c */

#include <iostream>
#include <string>

int main(int argc, char *argv[])
{
  std::string S;
  long long K;

  std::cin >> S >> K;

  int i;
  for (i = 0; i < int(S.length()); i++)
  {
    if (S.at(i) == '1')
    {
      if (i+1 == K) {
        std::cout << "1" << std::endl;
        return 0;
      }
    }
    else
    {
      std::cout << S.at(i) << std::endl;
      return 0;
    }
  }


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}

int main() {
  ll a, b;
  cin >> a >> b;
  map<ll, ll> a_map = prime_factor(a);
  map<ll, ll> b_map = prime_factor(b);
  ll ans = 1;
  for (auto iter = a_map.begin(); iter != a_map.end(); iter++) {
    if (b_map[iter->first] != 0) {
      ans += 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
A, B = map(str, input().split())
if int(A[0])+1 < int(B[0]):
    ans = (int(B[0]) - int(A[0]) - 1) * 10**2
    for i in range(int(A), (int(A[0])+1)*10000):
        a = str(i)
        if a[0] == a[4] and a[1] == a[3]:
            ans += 1
    for i in range((int(B[0])*10000), int(B)+1):
        b = str(i)
        if b[0] == b[4] and b[1] == b[3]:
            ans += 1

else:
    ans = 0
    for i in range(int(A), int(B)+1):
        a = str(i)
        if a[0] == a[4] and a[1] == a[3]:
            ans += 1

print(ans)


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

using namespace std;

int n;

void solve(){
    int i,j;
    string str;
    cin >> n;
    int a,b;
    cin >> a >> b;
    vector<int> p(n);
    int s,m,l;
    s = m = l = 0;
    for(i = 0;i < n;i++){
        cin >> p[i];
        if(p[i] > b) l++;
        else if(p[i] > a) m++;
        else s++;
    }

    long long ans = 0;
    cout << min(s,min(m,l)) << endl;
}

int main(){
    solve();
}


Measured memory_bytes: 256
// In His Name

#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define gcd __gcd
#define int long long
#define ull unsigned long long

using namespace std;

typedef pair<int, int> pii;

const int MAX = 3e3 + 10;
int n;
double ans, p[MAX], dp[MAX][MAX];

main (){
	cin >> n;
	for (int i = 0 ; i < n ; i++){
		cin >> p[i];
	}
	dp[0][0] = 1;
	for (int i = 1 ; i <= n ; i++){
		for (int j = 0 ; j <= i ; j++){
			if (j){
				dp[i][j] += dp[i - 1][j - 1] * p[i - 1];
			}
			dp[i][j] += dp[i - 1][j] * (1 - p[i - 1]);
		}
	}
	for (int i = (n + 1) / 2 ; i <= n ; i++){
		ans += dp[n][i];
	}
	cout << setprecision(12) << ans;
}

Measured memory_bytes: 69120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

void solve() {
    ll X;
    cin >> X;
    for ( ll a = 0; a < 1000; a++ ) {
        for ( ll b = 0; b < 1000; b++ ) {
            if ( a*a*a*a*a-b*b*b*b*b == X ) {
                cout << a << " " << b << "\n";
                return;
            }
            if ( a*a*a*a*a+b*b*b*b*b == X ) {
                cout << a << " " << -b << "\n";
                return;
            }
        }
    }
    return;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3492
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int n;
    cin >> n;
    vector<vector<int>> v(2, vector<int>(n+1, 0));
    fore(i,0,2) fore(j,1,n+1) {
        cin >> v[i][j];
        v[i][j] += v[i][j-1];
    }
    int mx = 0;
    fore(j,1,n+1) {
        int cnt = v[0][j]+(v[1][n]-v[1][j-1]);
        mx = max(mx, cnt);
    }
    cout << mx << endl;
}


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

int main(){
	int n,m;
	int* a;
	int* b;
	int* c;
	int* d;
	int i,j;
	int tmp;
	int min;
	int tmp_num;

	scanf("%d %d",&n,&m);
	a = (int*)calloc(n,sizeof(int));
	b = (int*)calloc(n,sizeof(int));
	c = (int*)calloc(m,sizeof(int));
	d = (int*)calloc(m,sizeof(int));

	for(i=0; i<n; i++){
		scanf("%d %d",a+i,b+i);
	}

	for(i=0; i<m; i++){
		scanf("%d %d",c+i,d+i);
	}

	for(i=0; i<n; i++){
		min = 200000001;
		for(j=0; j<m; j++){
			tmp = abs(a[i]-c[j]) + abs(b[i]-d[j]);
			if( tmp < min ){
				min = tmp;
				tmp_num = j;
			}
		}
		printf("%d\n",tmp_num+1);
	}
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;


int main(){
    ll H;
    cin >> H;
    ll N;
    cin >> N;
    vector<ll> A(N,0);
    vector<ll> B(N,0);
    for(ll i=0;i<N;i++){
        cin>>A[i]>>B[i]
    ;}

    //dp[i][j]はi番目までの魔法で体力i削るまでに消耗する魔力の最小値
    vector<vector<ll>> dp(N, vector<ll>(H+1, INF));
    for(ll i=0;i<N;i++){
        dp[i][0]=0;
    ;}
    //魔法を一つずつ解禁
    
    for(ll i=0;i<N;i++){
        for(ll j=0;j<H;j++){
            if(j>=A[i]){
                if(i>0)
            dp[i][j]=min(dp[i-1][j],dp[i][j-A[i]]+B[i]);
            if(i==0)dp[i][j]=dp[i][j-A[i]]+B[i];
            }
            else if(i>0)dp[i][j]=dp[i-1][j]
        ;}
        if(i>0)dp[i][H]=dp[i-1][H];
        for(ll j=1;j<=A[i]&&j<=H;j++){
            dp[i][H]=min(dp[i][H],dp[i][H-j]+B[i])
        ;}
    ;}
    cout<<dp[N-1][H]<<endl;

    return 0;
}


Measured memory_bytes: 78464
#include <iostream>
#include <algorithm>
#include <functional>
#include <set>
#include <vector>
#include <array>
#include <cmath>

#define r(i, n) for(int i = 0; i < n; i++)
#define re(i, n) for(int i = 0; i<=n; i++)

using namespace std;

int main() {
    int a, b;

    scanf("%d %d", &a, &b);
    if( b == 100 ) {
        a = a * 1000 + b;
    } else if ( b >= 10) {
        a = a * 100 + b;
    } else {
        a = a * 10 + b;
    }

    auto z = sqrt(a);
    int iz = (int)(z * 10);
    printf(iz % 10 == 0 ? "Yes" : "No");

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MODULO 1000000007
#define PI 3.14159265359
typedef long long int ll;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x;
    cin>>x;
    if(x>=30)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3644
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n; cin>>n;
    if(n==1){
        cout<<1<<endl; return 0;
    }
    string a[2002];
    for(int i=1; i<n; i++) cin>>a[i];
    bool dp[2][2002][2002];
    for(int i=0; i<n-1; i++){
        if(a[i+1][i]=='0'){
            dp[0][i][i+1]=1;
            dp[1][i][i+1]=0;
        }else{
            dp[0][i][i+1]=0;
            dp[1][i][i+1]=1;
        }
    }
    for(int d=2; d<n; d++){
        for(int i=0; i<n-d; i++){
            if(dp[1][i+1][i+d] && a[i+d][i]=='0'){
                dp[0][i][i+d]=1;
            }else{
                dp[0][i][i+d]=0;
                for(int j=i+1; j<i+d; j++){
                    if(dp[0][i][j] && dp[0][j][i+d]){
                        dp[0][i][i+d]=1;
                        break;
                    }
                }
            }
            if(dp[0][i][i+d-1] && a[i+d][i]=='1'){
                dp[1][i][i+d]=1;
            }else{
                dp[1][i][i+d]=0;
                for(int j=i+1; j<i+d; j++){
                    if(dp[1][i][j] && dp[1][j][i+d]){
                        dp[1][i][i+d]=1;
                        break;
                    }
                }
            }
        }
    }
    int ans=0;
    if(dp[0][0][n-1]) ans++;
    if(dp[1][0][n-1]) ans++;
    for(int i=1; i<n-1; i++){
        if(dp[1][0][i] && dp[0][i][n-1]) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

class number
{
public:
	int num;
	bool is_INF;
	number(){};
	number(const int n, const bool b);
	void show_n();
};

number::number(const int n, const bool b)
{
	num = n, is_INF = b;
}

void number::show_n()
{
	if(is_INF){ printf("INF"); }
	else{ printf("%d", num); }
}

number operator+(const number n1, const number n2)
{
	number n3;
	if(n1.is_INF || n2.is_INF){
		n3.num = 0, n3.is_INF = true;
	}else{
		n3.num = n1.num + n2.num;
		n3.is_INF = false;
	}
	return n3;
}

number min_ex(const number n1, const number n2)
{
	number n3;
	if(n1.is_INF && n2.is_INF){
		n3.num = 0, n3.is_INF = true;
	}else{
		n3.is_INF = false;
		if(n1.is_INF){ n3.num = n2.num; }
		else if(n2.is_INF){ n3.num = n1.num; }
		else{ n3.num = min(n1.num, n2.num); }
	}
	return n3;
}

int main()
{
    int i, j, n, m, from, to, cost;
    scanf("%d %d", &n, &m);

    number D[100][100];

	for(i = 0; i < n; i++){
		for(j = 0; j < n; j++){
			D[i][j] = (i == j ? number(0, false) : number(0, true));
		}
	}
    for(int k = 0; k < m; k++){
        scanf("%d %d %d", &from, &to, &cost);
        D[from][to] = number(cost, false);
    }

    for(int mid = 0; mid < n; mid++){
        for(i = 0; i < n; i++){
            for(j = 0; j < n; j++){
				D[i][j] = min_ex(D[i][j], D[i][mid] + D[mid][j]);
            }
        }
    }
    for(i = 0; i < n; i++){ if(D[i][i].num < 0){ printf("NEGATIVE CYCLE\n"); return 0; } }

    for(i = 0; i < n; i++){
        for(j = 0; j < n; j++){
			D[i][j].show_n();
                if(j < n - 1){ printf(" "); }
            }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define UF uftree
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign

class uftree 
{
    public:
        int size;
        vector<int> par, rank;
        uftree(int n) : size(n), par(n), rank(n) {
            for (int i = 0; i < size; i++) {
                par[i] =  i;
                rank[i] = 0;
            }
        }
        int find(int x) {
            if (par[x] == x) {
                return x;
            } else {
                return par[x] = find(par[x]);
            }
        }
        void unite(int x, int y) {
            x = find(x);
            y = find(y);
            if (x == y) {
                return ;
            }

            if (rank[x] < rank[y]) {
                par[x] = y;
            } else {
                par[y] = x;
                if (rank[x] == rank[y]) {
                    rank[x]++;
                }
            }
        }
        bool same(int x, int y) {
            return find(x) == find(y);
        }
};

struct edge {
    int from, to, len, cost;
};
int n, m;
struct edge data[10000];
pair<double, int> funami[10000];

void make(double x);
bool solve();

signed main()
{
    cin >> n >> m;
    rep(i, m) {
        cin >> data[i].from >> data[i].to >> 
            data[i].len >> data[i].cost;
    }

    double l = 0.0, r = 1.0;
    while (r - l > 0.000001) {
        double ans = (r + l) / 2;
        make(ans);
        //cout << ans << " ";
        if (solve()) {
            r = ans;
        } else {
            l = ans;
        }
    }
    printf("%.10lf\n", l);

    return 0;
}

bool solve()
{
    UF kyoko(n);
    double sum = 0.0;
    for (int i = m -1; i >= 0; i--) {
        if (kyoko.same( data[funami[i].second].from, 
                    data[funami[i].second].to)) {
            sum += funami[i].first;
        } else {
            kyoko.unite(data[funami[i].second].from,
                    data[funami[i].second].to);
        }
    }
    //cout << sum << endl;
    if (sum > 0) return false;
    else return true;
}


void make(double x)
{
    for (int i = 0; i < m; i++) {
        funami[i].first = data[i].cost - data[i].len * x;
        funami[i].second = i;
    }
    sort(funami, funami + m);
}

Measured memory_bytes: 3760
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>
#include<stack>
#include <utility>

const long long MOD = 1000000007;
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

llong dfs(llong x, llong y, vector<string> &Map, vector<vector<llong> > &dp){
    if(x<0 || y<0 || x>=Map[0].size() || y>=Map.size()){
        return 0;
    }
    if(Map[y][x]=='#'){
        return 0;
    }
    if(dp[y][x]!=-1){
        return dp[y][x];
    }
    if(x==0 && y==0){
        return 1;
    }
    llong ans=0;
    ans = (dfs(x-1, y, Map, dp)%MOD + dfs(x, y-1, Map, dp)%MOD)%MOD;
    dp[y][x] = ans;
    return ans;
}

int main(){
    llong H,W;
    cin >> H >> W;
    vector<string> Map(H);
    for(int i=0; i<H; i++){
        cin >> Map[i];
    }
    vector<vector<llong> > dp(H, vector<llong>(W, -1));
    cout << dfs(W-1, H-1, Map, dp)%MOD << endl;
    return 0; 
}


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

int main() {
    //int a, n, card[4][13] = { {} }, x = 0, y = 0, k = 0, q[52], tmp;
    
    int m,f,r,i=0;
    char c[100] = {};
    while (1) {
        cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1)break;
        if (m == -1 || f == -1) c[i]='F';
        else if (m + f >=80) c[i] = 'A';
        else if (m + f >= 65) c[i] = 'B';
        else if (m + f >= 50||(m + f >= 30 && r>=50)) c[i] = 'C';
        else if (m + f >= 30) c[i] = 'D';
        else  c[i] = 'F';
        i++;
    }
    for (int j = 0; j < i;j++) {
        printf("%c\n", c[j]);

    }

    return 0;
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
int const M=3e5+10,inf=1e9+10,mod=1e9+7;
int a,n,b;
int ans[M];
main()
{
	int n,k;
	cin>>n>>k;
	if(k==0)return cout<<n*n,0;
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(i<=k)continue;
		int tmp=n/i;
		tmp--;
		ans+=tmp*(i-k);
		int hlp=(tmp+1)*i;
		//cout<<hlp<<endl;
		if(hlp+k>n)continue;
		hlp+=k;
		ans+=n-hlp+1;
	}
	int tmp=n-k;
	cout<<ans+(tmp*(tmp+1))/2;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
int a,b,c,d,e;
scanf("%d %d %d",&a,&b,&c);
for(e=0;a<=b;a++)
   {
   d=c%a;
   if(d==0)
      {
      e=e+1;
      }
   }
printf("%d\n",e);
return 0;
}

Measured memory_bytes: 596
#include <stdio.h> 
#include <math.h>
 
int main(void)
{   
    int n, x[1000], y[1000],i;
    double p1 = 0, p2 = 0, p3 = 0, p = 0;
 
    scanf("%d",&n);
 
    for(i=0; i<n; i++)
    {
        scanf("%d", &x[i]);
    }
 
    for(i=0; i<n; i++)
    {
        scanf("%d", &y[i]);
    }
 
    for(i=0; i<n; i++)
    {
        if(x[i] < y[i])
        {
            p1 = p1 + y[i] - x[i];
            p3 = p3 + (y[i] - x[i]) * (y[i] - x[i]) * (y[i] - x[i]);
        }
        if(x[i] > y[i])
        {
            p1 = p1 + x[i] - y[i];
            p3 = p3 + (x[i] - y[i]) * (x[i] - y[i]) * (x[i] - y[i]);
        }
 
        p2 = p2 + (x[i] - y[i]) * (x[i] - y[i]);
 
        if(x[i] < y[i])
        {
            if(p < y[i] - x[i])
            {
                p = y[i] - x[i];
            }
        }
        if(x[i] > y[i])
        {
            if(p < x[i] - y[i])
            {
                p = x[i] - y[i];
            }
        }
    }
 
    printf("%f\n%f\n%f\n%f\n", p1, sqrt(p2), pow(p3, 1.0/3.0), p);
    return 0;
}

Measured memory_bytes: 680
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    A = []
    for _ in range(N):
        a, b = map(int, input().split())
        A.append((a, b))

    A = sorted(A, key=lambda x: x[1])
    time = 0
    for a, b in A:
        time += a
        if time > b:
            return 'No'

    return 'Yes'


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 33416
def string_two_numbers_spliter():
    a, b, c = [int(i) for i in input().split()]
    return a, b, c
 
 
def count_nums_of_divisors_of_c_in_a_and_b(a, b, c):
    count = 0
    for i in range(1, c+1):
        if (c % i == 0):
            if i >= a and i <= b:
                count += 1
    return count
 
 
def main():
    a, b, c = string_two_numbers_spliter()
    print(count_nums_of_divisors_of_c_in_a_and_b(a, b, c))
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 5604
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>
#include <cstdint>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef unsigned long long		SQWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	if (((abs(a - b) <= d)&&(abs(b - c) <= d))||(abs(a - c) <= d)) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}



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

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<long long> a(n);
    vector<long long> b(m);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }
    vector<long long> A(n+1);
    A[0] = 0;
    vector<long long> B(m+1);
    B[0] = 0;
    for (int i = 0; i < n; i++) {
        A[i+1] = A[i] + a[i];
    }
    for (int i = 0; i < m; i++) {
        B[i+1] = B[i] + b[i];
    }
    int ans = 0;
    int j = m;
    for (int i = 0; i < n+1; i++) {
        if (A[i] > k) {
            break;
        }
        while (B[j] > k - A[i]) {
            j--;
        }
        ans = max(ans, i+j);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9596
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define endl "\n"
#define fcout cout<<fixed<<setprecision(15)
typedef pair<int, int> P;
//struct edge { int to, cost; };

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; }

bool prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    return n != 1;
}
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int lcm(int x, int y) {
return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int modinv2(int a, int mod) {
    return mod_pow(a, mod - 2, mod);
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k, int mod) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= mod;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }
    return x * modinv(y, mod) % mod;
}

signed main() {
    //srand((unsigned)time(NULL));

    cin.tie(nullptr);
    ios::sync_with_stdio(false);

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

    int x = min(b-1, n);
    cout << ((x * a) / b) - a * (x / b) << endl;


    return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define x first
#define y second

using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll INF=0x3f3f3f3f;
const ll MAX=206005;
char s[MAX];
pll pt1,pt2;
vector<pll> fnt;
int n,lis[MAX],lim,rev;
const double PI=3.141592653589793;
double ans,f1=10*(2-PI/2.),f2=(PI-2)*10;
void bin(int x,int y,int r){
    if(y-x==1){
        lis[y]=r;
        lim=max(y,lim);
        return;
    }
    int p=(x+y)/2;
    if(lis[p]>r) bin(x,p,r);
    else bin(p,y,r);
}
int main(){
    scanf("%d%d%d%d",&pt1.x,&pt1.y,&pt2.x,&pt2.y);
    if(pt1.x>pt2.x) swap(pt1,pt2);
    if(pt1.y>pt2.y) rev=1,pt1.y=-pt1.y,pt2.y=-pt2.y;
    scanf("%d",&n);
    for(int i=0;i<n;i++) {
        pll tmp;
        scanf("%d%d",&tmp.x,&tmp.y);
        if(rev) tmp.y=-tmp.y;
        if(tmp.x>=min(pt1.x,pt2.x)&&tmp.x<=max(pt1.x,pt2.x)&&
           tmp.y>=min(pt1.y,pt2.y)&&tmp.y<=max(pt1.y,pt2.y)) fnt.push_back(tmp);
    }
    sort(fnt.begin(),fnt.end());
    for(int i=1;i<=n;i++) lis[i]=INF;
    lis[0]=-INF;
    for(int i=0;i<fnt.size();i++){
        bin(0,n+1,fnt[i].second);
    }
    ans+=100.*(double)(pt2.y-pt1.y+pt2.x-pt1.x)-(double)lim*f1;
    if(lim==pt2.x-pt1.x+1||lim==pt2.y-pt1.y+1) ans+=f2+f1;
    printf("%.20f\n",ans);
}


Measured memory_bytes: 6384
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
#define NUM 100005
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int GCD(int a,int b){int c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
int LCM(int a,int b){return a*b/GCD(a,b);}
int POW(int a,int n){int i;LL x=a;if(n==0)return 1;else if(n==1)return a;else FOR(i,0,n-1){x=x*a;if(x>MOD)x%=MOD;}return (int)x;}
int cmp(const void* a,const void* b){return *(int*)a-*(int*)b;}

int main() {
  int N,i,ans=0;
  scanf("%d",&N);
  int d[N];
  FOR(i,0,N)scanf("%d",&d[i]);
  qsort(d,N,4,cmp);
  ans=d[N/2]-d[N/2-1];

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


Measured memory_bytes: 892
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define invp(a,p)pom(a,p-2,p)

//全方位木DPとかいうやつ？
ll MOD;

//辺の情報を個別に持つタイプ
typedef struct edge{ll s,g;}E;
typedef struct graph{
	ll vcnt,ecnt;
	E  e[200010];//適宜変える
	ll id[100010];//適宜変える
}G;
G g;

int esort(const void*a,const void*b){
	E*p=(E*)a,*q=(E*)b;
	if((*p).s<(*q).s)return -1;
	if((*p).s>(*q).s)return  1;
	if((*p).g<(*q).g)return -1;
	return 1;
}

ll root[100010];
int st[100010],ptr;
void dfs(int k){
	st[ptr++]=k;
	rep(i,g.id[k],g.id[k+1])if(g.e[i].g!=root[k]){
		root[g.e[i].g]=k;
		dfs(g.e[i].g);
	}
}

void readgraph(){
	//適宜変える
	ll n;
	scanf("%lld%lld",&n,&MOD);
	rep(i,0,n-1){
		ll x,y;
		scanf("%lld%lld",&x,&y);
		x--,y--;
		g.e[2*i].s=x;
		g.e[2*i].g=y;
		g.e[2*i+1].s=y;
		g.e[2*i+1].g=x;
	}
	g.vcnt=n;
	g.ecnt=2*n-2;
	qsort(g.e,g.ecnt,sizeof(E),esort);

	int p=0;
	rep(i,0,g.vcnt){
		while(p<g.ecnt&&g.e[p].s<i)p++;
		g.id[i]=p;
	}
	g.id[g.vcnt]=g.ecnt;//一応番兵
	dfs(0);
}

ll dp1[100010];//dp1[i]=0を根とする根付き木とみて、頂点iを黒く塗るときの部分木の塗り方
ll dp2[100010];//dp2[i]=iを根として黒くしたとき、サイズが1小さい部分木であって0を含むものに対する塗り方

ll calc(int k){
	ll ans=1;
	//塗り方はΠ(dp1[*]+1)通り(+1は塗らない分)
	rep(i,g.id[k],g.id[k+1])if(g.e[i].g!=root[k]){
		ans=ans*(calc(g.e[i].g)+1)%MOD;
	}
	return dp1[k]=ans;
}

void f(int l,int r,ll s,int v){
	if(r-l==1){
		if(g.e[l].g==root[v])return;
		dp2[g.e[l].g]=s;
		return;
	}
	int m=(l+r)/2;
	ll temp=1;
	rep(i,l,m){
		if(g.e[i].g==root[v])temp=temp*(dp2[v]+1)%MOD;
		else temp=temp*(dp1[g.e[i].g]+1)%MOD;
	}
	f(m,r,s*temp%MOD,v);
	
	temp=1;
	rep(i,m,r){
		if(g.e[i].g==root[v])temp=temp*(dp2[v]+1)%MOD;
		else temp=temp*(dp1[g.e[i].g]+1)%MOD;
	}
	f(l,m,s*temp%MOD,v);
}

void calc2(int v){
	//dp2[*]を求める
	//vの子kについて、dp2[k]=Π(dp*[*]+1)である(積はkを除くvとつながってるやつ)
	//再帰的にえいえいするとO(NlogN)とかになりそう？なって
	ll l=g.id[v],r=g.id[v+1];
	if(l==r)return;
	f(l,r,1,v);
}


int main(){
	readgraph();
	printf("%lld\n",calc(0));
	rep(i,0,g.vcnt)calc2(st[i]);
	rep(i,1,g.vcnt)printf("%lld\n",dp1[i]*(dp2[i]+1)%MOD);
	return 0;
}

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

map<int, int> prime_factor(int n)
{
	map<int, int> res;
	for (int i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			++res[i];
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

void Main()
{
	int N; cin >> N;
	map<int, int> total_pf;
	REP(i,2,N + 1) {
		auto pf = prime_factor(i);
		for (auto p : pf) {
			total_pf[p.first] += p.second;
		}
	}
	ll res = 1;
	for (auto p : total_pf) {
		res = res * (p.second + 1) % 1000000007;
	}
	cout << res << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
const int INF = 100000000;

int main(){
    int n;
    cin >> n;
    vector<int> a(n + 1);
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    vector<int> b(n + 1, 0);
    int count2 = 0;
    for(int i = n/2 + 1; i <= n; i++){
        b[i] = a[i];
        if(b[i] == 1){
            count2++;
        }
    }
    
    int count1 = 0;
    for(int i = n/2; i>=1; i--){
        int tmp = n / i;
        int count = 0;
        for(int j = 2; j <= tmp; j++){
            count += b[i*j];
        }
        if(count % 2 != a[i]){
            b[i] = 1;
            count1++;
        }
    }

    cout << count1 + count2 << endl;
    for(int i = 1; i <= n; i++){
        if(b[i] == 1){
            cout << i << endl;
        }
    }
}

Measured memory_bytes: 2432
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

const int MAXN = 110;
int dp[MAXN][MAXN][MAXN], A[MAXN];

int solve(int l, int r, int prefix) {
    if(r - l == 0) return true;
    if(r - l == 1) return prefix >= 2;
    int &val = dp[l][r][prefix];
    if(val >= 0) return val;

    val = prefix >= 2 ? solve(l+1, r, 1) : false;
    for(int i=l+1; i<r; i++) {
        if(A[l] == A[i]) {
            val |= solve(l+1, i, 1) & solve(i, r, prefix + 1);
        }
    }

    /*
    if(val == true) {
        fprintf(stderr, "true: segment = [%lld, %lld), prefix = %lld\n", l, r, prefix);
    }
    */
    return val;
}

signed main() {
    int N; cin >> N;
    for(int i=0; i<N; i++) {
        cin >> A[i];
    }
    fill(dp[0][0], dp[N+1][0], -1);
    cout << (solve(0, N, 1) ? "yes" : "no") << endl;
    return 0;
}



Measured memory_bytes: 12648
#include<iostream>
#include <algorithm>
#include <math.h>
using namespace std;

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

Measured memory_bytes: 256
def prime_factorize(n):
    dic = {}
    while n % 2 == 0:
        if 2 in dic:
            dic[2] += 1
        else:
            dic[2] = 1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            if f in dic:
                dic[f] += 1
            else:
                dic[f] = 1
            n //= f
        else:
            f += 2
    if n != 1:
        if n in dic:
            dic[n] += 1
        else:
            dic[n] = 1
    return dic

n = int(input())

dic = prime_factorize(n)
ans = 0
for value in dic.values():
    left = 1
    right = value
    while left+1 < right:
        mid = (left+right) // 2
        if mid*(mid+1)//2 <= value:
            left = mid
        else:
            right = mid
    ans += left
print(ans)

Measured memory_bytes: 62964
#include <bits/stdc++.h>
using namespace std;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }

constexpr int b = 80 * 80 + 3;
constexpr int M = b * 2 + 3;

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

    int H, W;
    cin >> H >> W;
    vector<vector<int>> A(H, vector<int>(W));
    vector<vector<int>> B(H, vector<int>(W));
    cin >> A >> B;

    vector<bitset<M>> dp(W + 1);
    dp[1][b] = 1;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            int d = abs(A[i][j] - B[i][j]);
            dp[j + 1] |= dp[j];
            dp[j + 1] = (dp[j + 1] << d) | (dp[j + 1] >> d);
        }
    }
    printf("%d", dp.back()._Find_next(b - 1) - b);
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define IOS std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define FRE freopen("in.txt", "r", stdin);
#define endl "\n"
#define PI acos(-1.0)
typedef long long LL;
typedef pair<int, int> PII;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10, M = 1010;

int cnt[N];

void solve() {
	int n;
	cin >> n;
	for(int i = 1; i < n; i++) {
		int num;
		cin >> num;
		cnt[num]++;
	}
	for(int i = 1; i <= n; i++) cout << cnt[i] << endl;
}

int main() {
	//FRE;
	int t;
	solve();
	return 0;
}

Measured memory_bytes: 4348
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        String s = sc.next();

        char[] c = s.toCharArray();

        c[k-1] = Character.toLowerCase(c[k-1]);

        for (char tmp : c) {
            System.out.print(tmp);
        }
    }
}

Measured memory_bytes: 21972
import java.util.Scanner;

public class Main
{

    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);

        int x = scan.nextInt();
        int y = scan.nextInt();
        int s = scan.nextInt();
        while (x != 0 && y != 0 && s != 0) {
            int best = 0;
            for (int i = 1; i <= s; i++) {
                for (int t = 1; t <= s; t++) {
                    if (s == i * (x + 100) / 100 + t * (100 + x) / 100) {
                        int g = i * (y + 100) / 100 + t * (100 + y) / 100;
                        if (best < g) {
                            best = g;
                        }

                    }

                }
            }
            System.out.println(best);
            x = scan.nextInt();
            y = scan.nextInt();
            s = scan.nextInt();

        }
    }
}



Measured memory_bytes: 29256
#include<stdio.h>
 
 
 
int p[100],m[100][100];

 
int main(){
  int N,P,i,l,j,k,b;
 
  scanf("%d",&N);
  for(P=1;P<=N;P++){
    scanf("%d%d",&p[P-1],&p[P]);
  }
 
  for(P=1;P<=N;P++){
    m[P][P]=0;
  }
  //MCM(N);
 for(l=2;l<=N;l++){
    for(i=1;i<=N-l+1;i++){
      j = i + l - 1;
      m[i][j] = 100000;
      for(k=i;k<j;k++){
        b = m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j];
        if(m[i][j]>b) m[i][j]=b;
      }
    }
  }
  
  printf("%d\n",m[1][N]);
 
  return 0;
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, i, j, h;
    long long int sum = 0;
    scanf("%d", &n);
    int a[n];
    for (i=0; i<n; i++) scanf("%d", &a[i]);
    for (i=0; i<n; i++) {
        for (j=i+1; j<n; j++) {
            h = a[i]*a[j];
            sum += (long long int) h;
        }
    }
    printf("%lld\n", sum);
    return 0;
}


Measured memory_bytes: 256
#include<cstring>
#include<cstdio>
#define max(a,b) (a>b?a:b)
int dp[305][305][305],mk,len;
char a[305];
int main(){
	scanf("%s%d",a+1,&mk);
	len=strlen(a+1);
	for(int i=1;i<=len;i++)
		for(int j=i;j>=1;j--){
			if(i==j){for(int k=0;k<=mk;k++) dp[j][i][k]=1;continue;}
			for(int k=0;k<=mk;k++)
				if(k) dp[j][i][k]=max(dp[j+1][i-1][k-1]+2,max(dp[j+1][i-1][k]+(a[i]==a[j])*2,max(dp[j+1][i][k],dp[j][i-1][k])));
				else dp[j][i][k]=max(dp[j+1][i-1][k]+(a[i]==a[j])*2,max(dp[j+1][i][k],dp[j][i-1][k]));
		}
	printf("%d\n",dp[1][len][mk]);
}

Measured memory_bytes: 110336
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()


def main():
    x = II()
    for i in range(10**5):
        if (i+1)*i/2 >= x:
            return i
    return -1


print(main())


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

int main() {
  int N, K;
  cin >> N >> K;
  int d=0;
  for (int i=0; i<N; i++) {
    int x;
    cin >> x;
    if (x < (K-x)) {
      d += x;
    }
    else {
      d += (K-x);
    }
  }
  cout << d*2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 4e5 + 10;
#define fi first
#define se second
#define pb push_back
int n,a[N],b[N];
vector<int>v[N];
int t[N<<2];
#define mid (l+r>>1)
#define ls o<<1
#define rs o<<1|1
void up(int o,int l,int r,int p,int d){
  if(l==r){
    t[o]=d;
    return ;
  }
  if(p<=mid)up(ls,l,mid,p,d);
  else up(rs,mid+1,r,p,d);
  t[o]=max(t[ls],t[rs]);
}
int get(int o,int l,int r,int x,int y){
  if(x<=l&&r<=y)return t[o];
  int z=0;
  if(x<=mid)z=max(z,get(ls,l,mid,x,y));
  if(y>mid)z=max(z,get(rs,mid+1,r,x,y));
  return z;
}
int get(int o,int l,int r,int x){
  if(l==r)return t[o];
  int z=0;
  if(x<=mid)return get(ls,l,mid,x);
  else return get(rs,mid+1,r,x);
}
int len,cnt,c[N],ans[N];
void dfs(int x,int y){
  int pre=get(1,1,len,a[x]);
  int nx=get(1,1,len,1,c[x])+1;
  ans[x]=max(ans[y],nx);
  up(1,1,len,a[x],nx);
  for(auto k:v[x]){
    if(k==y)
      continue;
    dfs(k,x);
  }
  up(1,1,len,a[x],pre);
}
int main() {
  ios::sync_with_stdio(false);
  cin>>n;
  for(int i=1;i<=n;i++)cin>>a[i],b[++cnt]=a[i],b[++cnt]=a[i]-1;
  sort(b+1,b+1+cnt);
  len=unique(b+1,b+1+cnt)-b-1;
  for(int i=1;i<=n;i++){
    c[i]=lower_bound(b+1,b+1+len,a[i]-1)-b;
    a[i]=lower_bound(b+1,b+1+len,a[i])-b;
  }
  for(int i=1;i<n;i++){
    int s,t;
    cin>>s>>t;
    v[s].pb(t);
    v[t].pb(s);
  }
  dfs(1,0);
  for(int i=1;i<=n;i++)cout<<ans[i]<<'\n';
  return 0;
}

Measured memory_bytes: 37504
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
using namespace std;

long long power(long long a, long long b) {
    //a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
    }
  ll int binomial(ll int n, ll int k) 
{ 
    ll int C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll int i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (int j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 
  vector<int> pr;
void Sieve(ll int n) 
{ 
    bool prime[10000000];
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            pr.push_back(p);
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
}
 




//It reurns Fn,Fn+1
pair<int, int> fib (int n) {
    if (n == 0)
        return {0, 1};

    auto p = fib(n >> 1);
    int c = p.first * (2 * p.second - p.first);
    int d = p.first * p.first + p.second * p.second;
    if (n & 1)
        return {d, c + d};
    else
        return {c, d};
}


  
int main() {
   char n;
    cin>>n;
    if(isupper(n))
    {
        cout<<'A'<<endl;
    }
    else
    {
        cout<<'a'<<endl;
    }
}


Measured memory_bytes: 3596
def wa(int_n):
    str_n = str(int_n)
    ans = 0
    for i in range(len(str_n)):
        ans += int(str_n[i])
    return ans
    
n,a,b = map(int,input().split())
ans = 0
for i in range(n+1):
    if a<=wa(i)<=b:
        ans += i
print(ans)


Measured memory_bytes: 9088
# import math
# from collections import Counter

# N = int(input()) # 1行, 単数
# arg = list(map(int, input().split())) # 1行, 配列
# D = Counter(arg) # 出現数カウント

# print('Yes')
# print('No')
# print()


N = int(input()) # 1行, 単数

arg = list(map(int, input().split())) # 1行, 配列
m = 1

if 0 in arg:
  print(0)
else:
  for A in arg:
    m = A * m
    if m > 1000000000000000000:
      m = -1
      break;
  print(m)


Measured memory_bytes: 84816
using System;
using System.Linq;

class AtCoderCS {
    static void Main(string[] args) {
        int[] NM = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        int N = NM[0], M = NM[1];
        int[] A = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

        Console.WriteLine(Math.Max(N - A.Sum(), -1));
    }
}

Measured memory_bytes: 28964
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}




int main() {
	int n, a, b; cin >> n >> a >> b;
	int num;

	int sum,total=0;
	for (int i = 1; i <= n; i++) {
		sum = 0;
		num = i;
		for (int j = 0; j < 5; j++) {
			sum += num % 10;
			num = num / 10;
		}
		//cout << sum << endl;
		if (sum >= a && sum <= b) total += i;
	}

	cout << total << endl;

	return 0;
}

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

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N),S(N+1,0);
    rep(i,N){
        cin >> A[i];
    }   
    rep(i,N){
        S[i+1] = S[i] + A[i];
    }
    map<ll,ll> mp;
    rep(i,N+1){
        mp[S[i]]++;
    }
    ll sum = 0;
    for(auto& e:mp){
        sum += (e.second)*(e.second-1)/2;
    }
    cout << sum << endl;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int MAXN = 10 + 1e6;
const ll oo = 1 + 1e18;
const ll mod = 7 + 1e9;

long long n, ans = 0;

int main()
{
    #define TASK "ABC"
    #ifndef ONLINE_JUDGE
    freopen(TASK".inp","r",stdin);
    freopen(TASK".out","w",stdout);
    #endif ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n;

    int cnt = 0;

    while (n % 2 == 0)
    {
        cnt++;
        n /= 2;
    }

    /*int k = sqrt (2 * cnt);
    ans += k;
    if (cnt && k * k == 2 * cnt) ans--;*/

    int cur = 1, pluss = 1;

    while (cnt >= cur)
    {
        ans++, pluss++, cur += pluss;
    }

    for (int i = 3; i <= sqrt(n); i += 2)
    {
        cnt = 0;

        while (n % i == 0)
        {
            cnt++;
            n /= i;
        }

        /*k = sqrt (2 * cnt);
        ans += k;
        if (cnt && k * k == 2 * cnt) ans--;*/

        cur = 1, pluss = 1;

        while (cnt >= cur)
        {
            ans++, pluss++, cur += pluss;
        }
    }

    if (n > 2) ans++;

    cout << ans;

    return 0;
}











































Measured memory_bytes: 3672
N, K = map(int, input().split())
S = input()

out = 0
prev_letter = ''
for letter in S:
    if letter == prev_letter:
        out += 1
    prev_letter = letter

change = N - out - 1

if change >= 2 * K:
    out += 2*K
else:
    out = N - 1
    
print(out)

Measured memory_bytes: 3316
from math import sqrt

N = int(input())
ps = set()
for _ in range(N):
  ps.add(tuple(map(int, input().split())))
ps = list(ps)
ps.sort()

def cross3(a, b, c):
  return (b[0]-a[0])*(c[1]-a[1]) - (b[1]-a[1])*(c[0]-a[0])

def cross(a, b, c, d):
  return (b[0]-a[0])*(d[1]-c[1]) - (b[1]-a[1])*(d[0]-c[0])

# ps = [(x, y), ...]: ソートされた座標list
def convex_hull(ps):
  qs = []
  N = len(ps)
  for p in ps:
    # 一直線上で高々2点にする場合は ">=" にする
    while len(qs) > 1 and cross3(qs[-1], qs[-2], p) > 0:
      qs.pop()
    qs.append(p)
  t = len(qs)
  for i in range(N-2, -1, -1):
    p = ps[i]
    while len(qs) > t and cross3(qs[-1], qs[-2], p) > 0:
      qs.pop()
    qs.append(p)
  return qs

# キャリパー法(Rotating Calipers法)
# 凸多角形を回転しながら走査し、最遠点対を求める
def dist(a, b):
  return abs(a[0]-b[0]) + abs(a[1]-b[1])

def rotating_calipers(ps):
  qs = convex_hull(ps)
  n = len(qs)
  if n == 2:
    return dist(qs[0], qs[1])
  i = j = 0
  for k in range(n):
    if qs[k] < qs[i]: i = k
    if qs[j] < qs[k]: j = k
  res = 0
  si = i; sj = j
  while i != sj or j != si:
    res = max(res, dist(qs[i], qs[j]))
    if cross(qs[i], qs[i-n+1], qs[j], qs[j-n+1]) < 0:
      i = (i + 1) % n
    else:
      j = (j + 1) % n
  return res

if len(ps) == 1:
  print(0)
elif len(ps) == 2:
  print(dist(ps[0], ps[1]))
else:
  print(rotating_calipers(ps))


Measured memory_bytes: 44132