akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
  int N, K;
  cin >> N >> K;
  vector<ll> p(N);
  vector<ll> s(N+1);
  s[0] = 0;

  for (int i = 0; i < N; i++) {
    cin >> p[i];
    s[i+1] = s[i] + p[i];
  }

  ll m = 0;
  for (int i = 0; i < N - K + 1; i++) {
    m = max(m, s[K + i] - s[i]);
  }

  m += (ll) K;

  cout << fixed << setprecision(12) << ((double) m) / 2.0L << endl;

  return 0;
}


Measured memory_bytes: 3328
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	int k,p;cin>>k>>p;
	int p1=p-k+1;
	for(int i=0;i<k;i++){
		cout<<p1<<" ";
		p1++;
	}
	p1=p+1;
	for(int i=0;i<k-1;i++){
		cout<<p1<<" ";
		p1++;
	}
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#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,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
vl modinv;
void fillModInv(ll n, ll mod){
  modinv = vl(n+1);
  modinv[1] = 1;
  FOR(i,2,n+1){
    modinv[i] = modinv[mod%i] * (mod - mod/i) % mod;
  }
}
/*}}}*/
int main() {
  double x;
  cin >> x;

  ll ans = 0;
  ll cur = 100;

  while(cur<x){
    cur = floor(cur * 1.01);
    ans++;
  }
  
  //cout << fixed << setprecision(10);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair

const int MAX_N = 1000000;

int N;

int dp[MAX_N + 1], dp_odd[MAX_N + 1];

int main() {
    vector<int> tetra, tetra_odd;
    for (int i = 1; i <= 200; i++) {
        int a = i * (i+1) * (i+2) / 6;
        tetra.PB(a);
        if (a % 2 == 1) tetra_odd.PB(a);
    }

    REP(i, MAX_N + 1) {
        dp[i] = MOD;
        dp_odd[i] = MOD;
    }
    dp[0] = 0;
    dp_odd[0] = 0;

    REP(i, MAX_N) {
        REP(j, tetra.size()) {
            if (i + tetra[j] <= MAX_N) dp[i + tetra[j]] = min(dp[i + tetra[j]], dp[i] + 1);
        }
        REP(j, tetra_odd.size()) {
            if (i + tetra_odd[j] <= MAX_N) dp_odd[i + tetra_odd[j]] = min(dp_odd[i + tetra_odd[j]], dp_odd[i] + 1);
        }
    }
    
    while (true) {
        cin >> N;
        if (N == 0) break;
        printf("%d %d\n", dp[N], dp_odd[N]);
    }
    return 0;
}


Measured memory_bytes: 10896
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

int main()
{
    string sa, sb, sc;
    cin >> sa >> sb >> sc;

    queue<int> que[3];
    for (auto c: sa)
        que[0].push(c - 'a');
    for (auto c: sb)
        que[1].push(c - 'a');
    for (auto c: sc)
        que[2].push(c - 'a');
    
    int turn = 0;
    while (true)
    {
        if (que[turn].size() == 0)
        {
            cout << char(turn + 'A') << endl;
            return 0;
        }
        int next_turn = que[turn].front();
        que[turn].pop();
        turn = next_turn;
        // cout << char(turn + 'a') << endl;
    }
    return 0;
}

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

#define MAX 100010
using namespace std;

int n;
int vet[MAX];

void getPrimos(){
    int limite = MAX;
    int raiz = sqrt(limite);

    for(int i=2;i<=raiz;i++){
        if(vet[i] == 0){
            for(int j = 2*i;j<=limite;j+=i){
                vet[j] = 1;
            }
        }
    }
}

int main(){
    getPrimos();
    scanf("%d",&n);
    while(1){
        if(vet[n] == 0){
            printf("%d\n",n);
            break;
        }else n++;
    }
}


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

int main()
{
  int num,tmp;
  int a,b,c;
  cin >> num; 
  while(num-->0){
    cin >> a >> b >> c;
    if(b>a){
      tmp=a;
      a=b;
      b=tmp;
    }
    if(c>a){
      tmp=a;
      a=c;
      c=tmp;
    }
    if(a*a==b*b+c*c)
      cout << "YES" << endl;
    else cout << "NO" << endl;
  }
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    int n;
    cin >> n;
    cout << (n+1) / 2;
    return 0;
}

Measured memory_bytes: 256
# D
n, m = map(int, input().split())

X = [[int(i) for i in input().split()] for i in range(n)]
# 8パターン探索する
x_list = [[] for i in range(8)]
ans_list = []

for x,y,z in X:
    x_list[0].append(x+y+z)
    x_list[1].append(x+y-z)
    x_list[2].append(x-y+z)
    x_list[3].append(x-y-z)
    x_list[4].append(-x+y+z)
    x_list[5].append(-x+y-z)
    x_list[6].append(-x-y+z)
    x_list[7].append(-x-y-z)
for i in range(8):
    x_list[i].sort(reverse=True)
    ans_list.append(sum(x_list[i][:m]))
print(max(ans_list))

Measured memory_bytes: 3572
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main() {
  int N;
  vector<unsigned long long int> a;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int buf;
    cin >> buf;
    a.push_back(buf);
  }

  unsigned long long int counter = 0;
  while (true) {
    // int idx = -1;
    int c2 = 0;
    for (int i = 0; i < N; i++) {
      if (a[i] % 2 == 0) {
        a[i] /= 2;
        c2++;
      }
    }

    if (c2 == 0)
      break;
    counter += c2;
  }
  cout << counter << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
    int n;
    cin >>n;
    vector<int> l(n),r(n);
    rep(i,n) cin >>l[i] >>r[i];
    l.pb(0);
    r.pb(0);
    ++n;

    sort(all(l), greater<int>());
    sort(all(r));

    ll ans = 0;
    ll t = 0;
    rep(i,n){
        t += 2*(l[i]-r[i]);
        ans = max(ans, t);
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

ll gcd(ll n, ll m) {
    if(n < m) swap(n, m);
    if(n % m == 0) return m;
    return gcd(m, n % m);
}

int main() {
    ll A, B; cin >> A >> B;
    ll G = gcd(A, B);
    ll ans = 1;
    for(ll i = 2; i * i <= G; i++) {
        if(G % i != 0) continue;
        ans++;
        while(G % i == 0) {
            G /= i;
        }
    }
    if(G != 1) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1
//#define INFTY 1000000000000000000

int main(){
    LL n;
    cin >> n;
    vector<LL> a(n);
    for(LL i=0; i<n; i++){
        cin >> a[i];
    }
    LL sum=0;
    for(LL i=1; i<n; i++){
        if(a[i]<a[i-1]){
            sum+=a[i-1]-a[i];
            a[i]=a[i-1];
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 4836
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	int a[n],dp[n];
	for(int i=0;i<n;i++) cin>>a[i];
	dp[0]=0;
	for(int i=1;i<n;i++)
	{
		dp[i] = dp[i - 1] + abs(a[i] - a[i - 1]);
        for(int j = 2; j <= k and (i - j) >= 0; ++j){
            dp[i] = min(dp[i], dp[i - j] + abs(a[i] - a[i - j]));
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#define ll long long 
ll llmax(ll a, ll b){return a > b ? a : b;}
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    ll h[n + 1];
    int a[m + 1], b[m + 1];
    for(int i = 1; i <= n; i++)
        scanf("%lld",&h[i]);
    for(int i = 1; i <= m; i++)
        scanf("%d%d",&a[i],&b[i]);
    int ans = 0;
    ll p[n + 1];
    for(int i = 0; i <= n; i++)
        p[i] = -1;
    for(int i = 1; i <= m; i++){
        ll q = h[a[i]];
        ll r = h[b[i]];
        if(q < r){
            if(p[b[i]] != 0){
                p[a[i]] = 0;
                p[b[i]] = 1;
            }
            p[a[i]] = 0;
        }
        else if(q > r){
            if(p[a[i]] != 0){
                p[a[i]] = 1;
                p[b[i]] = 0;
            }
            p[b[i]] = 0;
        }
        else{
            p[a[i]] = 0;
            p[b[i]] = 0;
        }
    }
    for(int i = 1; i <= n; i++)
        if(p[i] == -1)
            p[i] = 1;
    for(int i = 1; i <= n; i++)
        if(p[i] == 1)
            ans ++;
    printf("%d\n",ans);
    return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		int N = readInt(); int arr[] = new int[N+1], tkn[] = new int[30], invalid = 0; long tot = 0;
		for(int i = 1; i<=N;i ++) arr[i] = readInt();
		for(int l = 1, r = 1; r<=N; r++) {
			for(int i = 0; i<22; i++) {if(((1<<i)&arr[r]) != 0) {tkn[i]++; if(tkn[i] == 2) invalid++;}}
			while(invalid > 0) {
				for(int i = 0; i<22; i++) {if(((1<<i)&arr[l]) != 0) {tkn[i]--; if(tkn[i] == 1) invalid--;}}
				l++;
			}
			tot += r-l+1;
		}
		println(tot);
		exit();
	}

	final private static int BUFFER_SIZE = 1 << 16;
	private static DataInputStream din = new DataInputStream(System.in);
	private static byte[] buffer = new byte[BUFFER_SIZE];
	private static int bufferPointer = 0, bytesRead = 0;
	static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	public static String readLine() throws IOException {
		byte[] buf = new byte[64]; // line length
		int cnt = 0, c;
		while ((c = Read()) != -1) {
			if (c == '\n')
				break;
			buf[cnt++] = (byte) c;
		}
		return new String(buf, 0, cnt);
	}

	public static String read() throws IOException {
		byte[] ret = new byte[1024];
		int idx = 0;
		byte c = Read();
		while (c <= ' ') {
			c = Read();
		}
		do {
			ret[idx++] = c;
			c = Read();
		} while (c != -1 && c != ' ' && c != '\n' && c != '\r');
		return new String(ret, 0, idx);
	}

	public static int readInt() throws IOException {
		int ret = 0;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');

		if (neg)
			return -ret;
		return ret;
	}

	public static long readLong() throws IOException {
		long ret = 0;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');
		if (neg)
			return -ret;
		return ret;
	}

	public static double readDouble() throws IOException {
		double ret = 0, div = 1;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();

		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');

		if (c == '.') {
			while ((c = Read()) >= '0' && c <= '9') {
				ret += (c - '0') / (div *= 10);
			}
		}

		if (neg)
			return -ret;
		return ret;
	}

	private static void fillBuffer() throws IOException {
		bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
		if (bytesRead == -1)
			buffer[0] = -1;
	}

	private static byte Read() throws IOException {
		if (bufferPointer == bytesRead)
			fillBuffer();
		return buffer[bufferPointer++];
	}

	public void close() throws IOException {
		if (din == null)
			return;
		din.close();
	}

	static void print(Object o) {
		pr.print(o);
	}

	static void println(Object o) {
		pr.println(o);
	}

	static void flush() {
		pr.flush();
	}

	static void println() {
		pr.println();
	}

	static void exit() throws IOException {
		din.close();
		pr.close();
		System.exit(0);
	}
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

const int N=205; int P;

int mul(int a,int b){ return 1ll*a*b%P; }
int add(int a,int b){ a+=b; return a>=P?a-P:a; }
int sub(int a,int b){ a-=b; return a<0?a+P:a; }
int gcd(int a,int b){ return !b?a:gcd(b,a%b); }

int n, lim, f[N][N], C[N][N], fac[N], ans; 

int calc(int k, int l, int lim) {
	rep(i, 1, l) {
		lop(j, 0, k) {
			if (i == 1 && !j) f[i][j] = 1; else f[i][j] = 0;
			if (i) f[i][j] = add(f[i][j], f[i-1][j]); 
			if (j) f[i][j] = add(f[i][j], f[i][j-1]); 
			if (l-i+1+j-1 > lim && j) f[i][j] = 0; 
		}
		lop(j, 0, k) if (k-j+i-1 > lim) f[i][j] = 0; 
	}
	int ans = 0; 
	lop(j, 1, k) ans = add(ans, f[l][j]); 
	return ans; 
}

int solve(int lim, int n) {
	if (n == 1) return 0; 
	if (n == 0) return 1; 
	if (lim < 0) return 0; 
	int r = 0; 
	rep(k, 1, min(n,lim+1)) {
		int t = mul(C[n-1][k-1], mul(fac[n-k], fac[k-1]));
		r = add(r, mul(t, calc(k, n-k, lim))); 
	}
	return r;
}

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
#endif
	cin >> n >> lim >> P; 
	C[0][0] = 1; 
	rep(i, 1, n) {
		C[i][0] = 1; 
		rep(j, 1, i) C[i][j] = add(C[i-1][j], C[i-1][j-1]); 
	}
	fac[0] = 1; 
	rep(i, 1, n) fac[i] = mul(fac[i-1], i); 
	rep(i, 0, lim+1) {
		ans = add(ans, mul(mul(fac[i], C[n][i]), solve(lim - i, n - i))); 
	}
	cout << ans << endl;
	return 0;
}


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





int main(){
   int n;
   cin>>n;
   vector<int> s;
   int m;
   ll cnt=0;
   rep(i,n){
      cin>>m;
      s.push_back(m);
   }
   sort(s.begin(),s.end(), std::greater<int>() );
  
   rep(i,n-2){
      rep(j,n-2-i){
         rep(k,n-2-i-j){
            if(s[i]<s[j+1+i]+s[k+2+i+j])cnt++;
         }
      }
   }
   cout<<cnt<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector < ll > a , b , c , d;
    ll n , W , z = 0;
    cin >> n >> W;
    ll w[n] , v[n];
    cin >> w[0] >> v[0];
    a.push_back( v[0] );
    for( int i = 1 ; i < n ; i++ ) {
        cin >> w[i] >> v[i];
        if( w[i] == w[0] ) a.push_back( v[i] );
        else if( w[i] == w[0] + 1 ) b.push_back( v[i] );
        else if( w[i] == w[0] + 2 ) c.push_back( v[i] );
        else d.push_back( v[i] );
    }
    sort( a.begin() , a.end() ); reverse( a.begin() , a.end() );
    sort( b.begin() , b.end() ); reverse( b.begin() , b.end() );
    sort( c.begin() , c.end() ); reverse( c.begin() , c.end() );
    sort( d.begin() , d.end() ); reverse( d.begin() , d.end() );
    for( int i = 0 ; i <= a.size() ; i++ ) {
        for( int j = 0 ; j <= b.size() ; j++ ) {
            for( int k = 0 ; k <= c.size() ; k++ ) {
                for( int l = 0 ; l <= d.size() ; l++ ) {
                    if( w[0] * i + ( w[0] + 1 ) * j + ( w[0] + 2 ) * k + ( w[0] + 3 ) * l <= W ) {
                        ll x = 0;
                        for( int m = 0 ; m < i ; m++ ) x += a[m];
                        for( int m = 0 ; m < j ; m++ ) x += b[m];
                        for( int m = 0 ; m < k ; m++ ) x += c[m];
                        for( int m = 0 ; m < l ; m++ ) x += d[m];
                        z = max( z , x );
                    }
                }
            }
        }
    }
    cout << z;
}





Measured memory_bytes: 256
#!/usr/bin/ruby
# encoding: utf-8

N = gets.to_i
V = gets.split.map(&:to_i)
C = gets.split.map(&:to_i)

ans = 0

(0..N-1).each do |i|
  if V[i] >= C[i]
    ans += (V[i]-C[i])
  end
end

puts ans


Measured memory_bytes: 1788
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int n,k,i,ans=1;
int main()
{
    //freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>n>>k;
    for(i=1;i<=n;i++)
	{
		if(ans*2<=ans+k)ans*=2;
		else ans+=k;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
#include <numeric>
using namespace std;

int main(){
    long long N;
    long long A[100000];
    long long M[100000];
    long long total = 0, sub = 0;
    cin>>N;
    for(int i=0;i<N;i++){
        long long a;
        cin>>a;
        total += a;
        A[i] = a;
        if (i % 2 == 1) {
            sub += a;
        }
    }
    M[0] = total - 2 * sub;
    printf("%lld ", M[0]);
    for (int i = 1; i < N; ++i) {
        long long m = 2 * A[i - 1] - M[i - 1];
        M[i] = m;
        printf("%lld", M[i]);
        if (i != N - 1) {
            printf(" ");
        }
        else {
            printf("\n");
        }
    }
//     printf("%d", N);
//     for (int i = 0; i < N; ++i) {
//         printf("%d, ", A[i]);
//     }

    return 0;
}


Measured memory_bytes: 2816
/*input
????C?????B??????A???????
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

ll preA[maxn],pre[maxn];
ll sufC[maxn],suf[maxn];

int main()
{
	IOS;
	string s;
	cin>>s;
	REP(i,SZ(s)){
		pre[i+1]=pre[i]+(s[i]=='?');
		preA[i+1]=preA[i]+(s[i]=='A');
		suf[i+1]=suf[i]+(s[SZ(s)-1-i]=='?');
		sufC[i+1]=sufC[i]+(s[SZ(s)-1-i]=='C');
	}
	ll ans=0;
	int n=SZ(s);
	REP(i,n){
		if(s[i]=='B'||s[i]=='?'){
			int l=i,r=n-1-i;
			int cnt=pre[l]+suf[r];
			ans+=preA[l]*sufC[r]%MOD*mypow(3,cnt)%MOD;
			if(pre[l]>0) ans+=pre[l]*sufC[r]%MOD*mypow(3,cnt-1)%MOD;
			if(suf[r]>0) ans+=preA[l]*suf[r]%MOD*mypow(3,cnt-1)%MOD;
			if(pre[l]>0&&suf[r]>0) ans+=pre[l]*suf[r]%MOD*mypow(3,cnt-2)%MOD;

			while(ans>=MOD) ans-=MOD;
		}
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 7376
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1<<20;
void solve() {
    int K;
    R(K);
    int now=0;
    FOR(i,1,SIZE){
        now=(now*10+7)%K;
        if(!now){
            W(i);
            return;
        }
    }
    W(-1);
}
int main(){
#define MULTITEST 0
#if MULTITEST    
    CASET{
        solve();
    }
#else
    solve();
#endif
    return 0;
}


Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=4e2+20;
const ll mod=1e9+7;
ll n,c,a[N],b[N];
ll dp[N][N];
ll p[N][N],pre[N][N];
int main()
{
	p[0][0]=1;
	for(ll i=1;i<=400;i++)
	{
		p[i][0]=1;
		pre[i][0]=1;
		for(ll j=1;j<=400;j++)
		{
			p[i][j]=(p[i][j-1]*i)%mod;		
		}
	}
	for(ll i=1;i<=400;i++)
		for(ll j=0;j<=400;j++)
			pre[i][j]=(pre[i-1][j]+p[i][j])%mod;
	while(cin>>n>>c)
	{
		for(int i=1;i<=n;i++)
			scanf("%I64d",&a[i]);
		for(int i=1;i<=n;i++)
			scanf("%I64d",&b[i]);
		memset(dp,0,sizeof(dp));
		dp[0][0]=1;
		for(int i=1;i<=n;i++)
		{
			for(int j=0;j<=c;j++)
			{
				for(int x=0;x<=j;x++)
				{
					ll t=(pre[b[i]][x]-pre[a[i]-1][x]+mod)%mod;
					dp[i][j]=(dp[i][j]+dp[i-1][j-x]*t)%mod;
				}
			}
		}
		cout<<dp[n][c]<<endl;	
	}
	return 0;
}

Measured memory_bytes: 4352
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int N, K, x[112];
int ans;

int main()
{
	in >> N >> K;
	rep(i, N) { in >> x[i]; }

	rep(i, N)
	{
		ans += std::min((x[i] - 0) * 2, (K - x[i]) * 2);
	}

	out << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <vector>
#include <deque>

using namespace std;
int n, m;

int main() {
    cin >> n >> m;
    vector<pair<int, int>> digit(m);
    for (int i = 0; i < m; ++i) {
        cin >> digit[i].first >> digit[i].second;
    }

    for (int x = 0; x < 1000; ++x) {
        int nx = x;
        int num_of_digits = 1;

        vector<int> num;
        num.push_back(nx % 10);
        nx /= 10;

        while (nx > 0) {
            num_of_digits++;
            num.push_back(nx % 10);
            nx /= 10;
        }
        if (num_of_digits != n) continue;

        reverse(num.begin(), num.end());
        bool valid = true;
        for (int i = 0; i < m; ++i) {
            if (num[digit[i].first - 1] != digit[i].second) {
                valid = false;
            }
        }
        if (valid) {
            cout << x << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
// #include "ext/pb_ds/assoc_container.hpp"
// #include "ext/pb_ds/tree_policy.hpp"
// #define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
//using namespace __gnu_pbds;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;
#define deb1a(v) cout << #v << "--->" << endl; for (auto it : v)  cout << it << " "; cout << endl;
#define deb2a(v) cout << #v << "--->" << endl;for (auto it:v){for(auto it1 : it){cout << it1 << " ";}cout<< endl;}
#define deb3a(v) cout << #v << "-->" << endl; for(auto it:v){cout << it.fi << " " << it.se << endl;}
#define mod 1000000007
#define so(v) sort(v.begin(),v.end())
#define fi first
#define se second
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
int power(int x, unsigned int y, int p){ int res = 1;x = x % p;while (y > 0)  { if (y & 1)res = (res*x) % p;y = y>>1;  x = (x*x)% p;} return res;}
int mI(int a, int m)  {return power(a, m - 2, m);}
vector<int> v;






int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x,x1=100;
    cin >> x;
    int ans = 0;
    while(x1<x){
        ans++;
        x1 += (x1 / 100);
    }
    cout << ans;
}


Measured memory_bytes: 3632
n,m=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
mod=10**9+7
h=[]
for i in range(n):
    h.append(x[i]-x[0])
x=h
h=[]
for i in range(m):
    h.append(y[i]-y[0])
y=h

s=0
for i in range(n):
    s=(s+x[i])%mod
t=0
for i in range(m):
    t=(t+y[i])%mod

data=[s]
for i in range(1,n):
    u=data[-1]-(x[i]-x[i-1])*(n-i)
    data.append(u)
s=0
for v in data:
    s=(s+v)%mod
data=[t]
for i in range(1,m):
    u=data[-1]-(y[i]-y[i-1])*(m-i)
    data.append(u)
t=0
for v in data:
    t=(t+v)%mod

print(s*t%mod)

Measured memory_bytes: 90468
#include <bits/stdc++.h>
using namespace std;
template<class C>constexpr int sz(const C&c){return int(c.size());}
using ll=long long;constexpr const char nl='\n',sp=' ';

int main() {
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);
  // freopen("err.txt", "w", stderr);
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int D, T, S;
  cin >> D >> T >> S;
  cout << (D <= T * S ? "Yes" : "No") << nl; 
  return 0;
}


Measured memory_bytes: 3660
#include <stdio.h>
#include <algorithm>

using namespace std;

//long long
const long long NN = 120000;
const long long mod = 1000000007;
long long n;
long long a[NN] , pos[NN];
long long fact[NN] , rev[NN];
long long l , r;
long long ans[NN];
long long pow ( long long f , long long x ) {
	long long s = 1;
	while ( x ) {
		if ( x % 2 == 1 ) s = (s*f) % mod;
		f = (f*f) % mod; x >>= 1;
	}
	return s;
}
long long C ( long long x , long long y ) {
	if ( y < 0 ) return 0;
	if ( x < y ) return 0;
	return ( ((fact[x]*rev[y])%mod) * rev[x-y] ) % mod;
}
void work () {
	long long i;
	scanf ( "%lld" , &n );
	for ( i = 1 ; i <= n + 1 ; i++ ) {
		scanf ( "%lld" , &a[i] );
		if ( pos[a[i]] ) {
			l = pos[a[i]];
			r = i;
		}
		pos[a[i]] = i;
	}
	fact[0] = 1;
	rev[0] = 1;
	for ( i = 1 ; i <= n + 1 ; i++ ) {
		fact[i] = ( fact[i-1] * i ) % mod;
	}
	rev[n+1] = pow ( fact[n+1] , mod - 2 );
	for ( i = n ; i >= 1 ; i-- ) {
		rev[i] = (rev[i+1]*(i+1)) % mod;
	}
	for ( i = 1 ; i <= n + 1 ; i++ ) {
		ans[i] = C(n+1,i);
		ans[i] = (ans[i] - C(n+1-r+1-1+l-1,i-1) + mod + mod) % mod;
	}
	for ( i = 1 ; i <= n + 1 ; i++ ) {
		printf ( "%lld\n" , ans[i] );
	}
}
int main () {
	work ();
	return 0;
}

Measured memory_bytes: 5376
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
ll n, m;
ll a[3001];
ll dp[3001];
const ll mod = 998244353;
int main()
{
	scanf("%lld %lld", &n, &m);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
	}
	ll dap = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i] > m)continue;
		if (a[i] == m) {
			dap += i * (n - i + 1);
			dap %= mod;
		}
		else {
			dap += (dp[m - a[i]] * (n - i + 1));
			dap %= mod;
		}
		for (int y = m; y >= a[i]; y--) {
			dp[y] += dp[y - a[i]];
			dp[y] %= mod;
		}
		dp[a[i]] += i;
		dp[a[i]] %= mod;
	}
	printf("%lld\n", dap);
}

Measured memory_bytes: 256
ans = []

while True :
    try :
        N = int(input())
        used = []

        cnt = 0
        
        for a in range(10) :
            for b in range(10) :
                for c in range(10) :
                    for d in range(10) :
                        if a + b + c + d == N :
                            cnt += 1

        print(cnt)

    except :
        break



Measured memory_bytes: 5588
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GS(S);
  int ans = 0, k = S.size();
  FOR(i, k) if (S[i] == 'o') ans++;
  print(ans + 15 - k >= 8 ? "YES" : "NO");
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	char s[20];
	int i;
	scanf("%s",s);
	for(i=0;i<19;i++){
		if(i==5 || i==13){
			s[i]=' ';
		}
	}
	printf("%s\n",s);
	return 0;
}

Measured memory_bytes: 128
// Your day breaks, your mind aches
// You find that all the words of kindness linger on
// When she no longer needs you
//#pragma GCC optimize ("Ofast,unroll-loops")
//#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;
#define fastio ios::sync_with_stdio(0);cin.tie(0)
#define debug(x) cout << #x << " = " << x << endl
#define For(i,a,b) for (int i = a; i < b; i++)
#define roF(i,a,b) for (int i = a; i >= b; i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) (v).begin(),(v).end()

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int N = 1e6;
const ll INF = 1e18;
const ld EPS = 10e-9;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll random(ll a, ll b) { return uniform_int_distribution<ll> (a, b) (rng); }

int main() {
	fastio;
	int n;
	string s, t;
	cin >> n >> s >> t;
	string ans = "";
	For(i,0,n) {
		ans += s[i];
		ans += t[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  if(a > b){
    cout << 2 * a - 1 << endl;
  }else if(a == b){
    cout << 2 * a << endl;
  }else{
    cout << 2 * b - 1 << endl;
  }
  return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b)
{
    return b ? gcd(b, a % b) : a;
}
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

pii func(int x)
{
    int a = x % 10;
    int b = 0;
    while (x)
    {
        b = x;
        x /= 10;
    }
    return pii(a, b);
}

int main()
{
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld", &N);
    map<pii, int> freq;
    rep1(i, N)
    {
        pii p = func(i);
        freq[p]++;
    }
    int ans = 0;
    rep1(i, N)
    {
        pii p = func(i);
        pii q(p.second, p.first);
        ans += freq[q];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
 class Soln{
	private String name;
	private int score;
    private int num ;
	
	public Soln(String name,int score,int num){
	this.name=name;
	this.score=score;
	this.num=num;
	}

	public int getScore(){
		return this.score;
	}

	public String getName(){
		return this.name;
	}

	public int getNum(){
		return this.num;
	}
}

class Main{
	public static void main(String args[]){
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int pos = 1;
	List<Soln> rest = new ArrayList<Soln>();
	for(int i =1;i<=n;i++){
	String name = sc.next();
	int score = sc.nextInt();
	rest.add(new Soln(name,score,pos));
	pos+=1;
	}

	Comparator<Soln>com = new Comparator<Soln>(){
            @Override
            public int compare(Soln s1,Soln s2){
            	if(!s1.getName().equals(s2.getName()))
            		return s1.getName().compareTo(s2.getName());
                
                else if(s1.getName().equals(s2.getName())){
                    
                    return (s1.getScore()>s2.getScore())?-1:1;
                    
                    
                }
                else
                return -1;   
        }
        };


        Collections.sort(rest,com);
        for(Soln st: rest){
System.out.println(st.getNum());		}
	
	}
}

Measured memory_bytes: 23764
import heapq
N, M = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a)
for i in range(M):
    tmp = heapq.heappop(a)
    if tmp % 2 == 0:
        tmp //= 2
    else:
        tmp //= 2
        tmp += 1
    heapq.heappush(a,tmp)
print(sum(a)*(-1))

Measured memory_bytes: 14180
A, V = gets.split.map(&:to_i)
B, W = gets.split.map(&:to_i)
T = gets.to_i
if A < B
  print A+(V*T) >= B+(W*T) ? "YES" : "NO"
else
  print A-(V*T) <= B-(W*T) ? "YES" : "NO"
end

Measured memory_bytes: 14300
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int N;
  cin >> N;
    
  vector<int> height(N);
  for(int i = 0; i < N; i++)
  {
    cin >> height.at(i);
  }
  long long sum = 0;
  
  for(int i = 0; i < N-1; i++)
  {
    if(height.at(i) > height.at(i + 1) )
    {
      sum += height.at(i) -height.at(i+1);
      height.at(i+1) = height.at(i);
    }
  }
  cout << sum;
}

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

# define pb push_back
# define fr first
# define sc second
# define mk make_pair

using namespace std;

const int inf = 1000000000 + 7;
const int N = 1e6 + 5;

typedef long long ll;

ll n, ans, sum;

inline void solve()
{
    cin >> n;

    for(int i = 1; i <= 100000; i ++)
    {
        sum += i;
        ans = i;
        if(sum >= n)
            break;
    }
    cout << ans << endl;
}

int tests = 1;

int main()
{
//    scanf("%d", &tests);

    while(tests --)
        solve();
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**9)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

k = ni()
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(a[k-1])

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

int main(){
  set<char> s;
  char tmp;
  for(int i=0;i<3;i++){
    cin >> tmp;
    s.insert(tmp);
  }
  if(s.size()==3){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
s = input()


def recursion(n,sum,l):
    #print(n,sum,l)

    if n == len(s):
        if sum == 7:
            print(s[0]+l[1]+s[1]+l[2]+s[2]+l[3]+s[3]+"=7")
            exit()
        return sum

    '''プラスの場合'''
    l[n] = "+"
    recursion(n+1, sum + int(s[n]),l)

    '''マイナスの場合'''
    l[n] = "-"
    recursion(n+1, sum - int(s[n]),l)



l = [[] for i in range(len(s))]
recursion(0,0,l)


Measured memory_bytes: 3064
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <climits>
#include <cmath>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll gcd(ll a, ll b){return b? gcd(b, a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  ull K;
  cin >> S >> K;
  int firstOne = 0;
  char firstNotOne;
  for(int i = 0; i < S.length(); i++){
    if(S.at(i)=='1'){
      firstOne++;
    }else{
      firstNotOne= S.at(i);
      break;
    }
  }
  char ans;
  if(K <= firstOne){
    ans = '1';
  }else{
    ans = firstNotOne;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        StringBuilder builder = new StringBuilder(scan.next());
//        String str = scan.next();
        int q = scan.nextInt();
        String command = "";

        for (int i = 0; i < q; i++) {
            command = scan.next();
            int a = scan.nextInt();
            int b = scan.nextInt() + 1;
            if (command.equals("replace")) {
                String p = scan.next();
                builder = builder.replace(a, b, p);
            } else if (command.equals("reverse")) {
                StringBuilder tmp = new StringBuilder(builder.substring(a, b));
                String tmp2 = tmp.reverse().toString();
                builder = builder.replace(a, b, tmp2);
            } else if (command.equals("print")) {
                System.out.println(builder.substring(a, b));
            }
        }
    }
}

Measured memory_bytes: 29180
#include <bits/stdc++.h>
#define ll long long
#define uint unsigned long long
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e-9
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
bool vis[19];
bool check(int a)
{
	while(a > 0)
	{
		if(vis[a % 10]) return false;
		a /= 10;
	}
	return true;
}
int main()
{
	int n,k,a;
	cin >> n >> k;
	memset(vis, 0, sizeof(vis));
	rep(i, 1, k)
	{
		cin >> a;
		vis[a] = true;
	}
	while(1)
	{
		if(check(n))
		{
			cout << n << endl;
			break;
		}
		n ++;
	}
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
const int N=400002;
int n,q,i,j,k,a,b,c,h[N],t[N],v[N],w[N];
long long d[N];
void dfs(int i,int fa){
	for(int j=h[i];j;j=t[j])
		if(v[j]!=fa){
			d[v[j]]=d[i]+w[j];
			dfs(v[j],i);
		}
}
int main(){
	scanf("%d",&n);
	for(i=1;i<n;i++){
		scanf("%d%d%d",&a,&b,&c);
		t[++k]=h[a];h[a]=k;v[k]=b;w[k]=c;
		t[++k]=h[b];h[b]=k;v[k]=a;w[k]=c;
	}
	scanf("%d%d",&q,&k);
	dfs(k,0);
	while(q--){
		scanf("%d%d",&a,&b);
		printf("%lld\n",d[a]+d[b]);
	}
	return 0;
}

Measured memory_bytes: 13312
n, x = map(int, input().split())
d = [1]
for _ in range(50):
    d.append(d[-1] * 2 + 3)
ans = 0
def f(i, h):
    if h == 0:
        return 1 if i == 1 else 0
    if i == 0:
        return 0
    mid = d[h-1] + 1
    if i <= mid:
        return f(i-1, h-1)
    if i == mid + 1:
        return 2 ** h
    if i <= d[h] - 1:
        return 2 ** h + f(i-mid-1, h-1)
    else:
        return 2 ** (h + 1) - 1
print(f(x, n))


Measured memory_bytes: 3064
program main
	integer D, N
	read(*, *) D, N
	if(D == 0) then
		if(N == 100) then
			write(*, *) N+1
		else
			write(*, *) N
		end if
	else if(D == 1) then
		if(N == 100) then
			write(*, *) N*(100**D) + 100
		else
			write(*, *) N*(100**D)
		end if
	else if(D == 2) then
		if(N == 100) then
			write(*, *) N*(100**D) + 10000
		else
			write(*, *) N*(100**D)
		end if
	end if
end program main

Measured memory_bytes: 768
#include <cstdio>
#include <iostream>
#include <vector>
#include <iomanip>
#include <fstream>
#include <map>
#include <algorithm>
#include <unordered_map>
#include <cmath>
#include <queue>

#define maxn 20010
#define inf 1e9

using namespace std;
int n;
int a[maxn], b[maxn], p[maxn], pos[maxn];

int main() {
    // freopen("POLYGON.in", "r", stdin);
    // freopen("POLYGON.out", "w", stdout);
    cin >> n;
    
    for (int i = 1; i <= n; ++i) {
        cin >> p[i];
        pos[p[i]] = i;
    }
    
    int val = 0;
    for (int i = 1; i <= n; ++i) {
        a[i] = a[i-1] + 1;
        b[i] = b[i-1] - 1;
        int newval = a[i] + b[i];
        if (newval < pos[i]) {
            a[i] += pos[i] - newval;
        } else {
            b[i] += pos[i] - newval;
        }
    }
    
    for (int i = 1; i <= n; ++i) {
        b[i] += 400000000;
    }
    
    for (int i = 1; i <= n; ++i) {
        cout << a[i] << " ";
    }
    cout << "\n";
    for (int i = 1; i <= n; ++i) {
        cout << b[i] << " ";
    }
}

Measured memory_bytes: 896
import java.util.Scanner;
import java.util.List;
import java.util.LinkedList;
import java.util.Deque;
import java.util.ArrayDeque;
import java.util.Collections;

public class Main{

	public static void main(String... args){
		Scanner scan = new Scanner(System.in);
		LinkedList<Double> values = new LinkedList<>();
		Deque<Double> stack = new ArrayDeque<>();
		
		int num = scan.nextInt();
		for(int i = 0; i < num; i++){
			values.add(scan.nextDouble());
		}
		
		Collections.sort(values);
		stack.push(values.poll());
		
		while(!values.isEmpty()){
			stack.push((stack.pop() + values.poll()) / 2.0);
		}
		
		System.out.println(stack.pop());
		
	}
}

Measured memory_bytes: 23380
#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>
#include <fstream>
#include <list>
#include <cctype>

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 vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a * b / gcd(a, b);
}

int main() {
	string str; cin >> str;
	int k; cin >> k;
	vector<string> sub;

	for (int i = 1; i <20; i++) {
		for (int j = 0; j < str.size(); j++) {
			if (i <= str.size() - j) {
				sub.push_back(str.substr(j, i));
			}
		}
	}
	sort(sub.begin(), sub.end());
	sub.erase(unique(sub.begin(), sub.end()), sub.end());

	//printVec1(sub);
	//cout << sub[3] << " " << sub[4];
	cout << sub[k-1];



	cout << endl;
	return 0;
}

Measured memory_bytes: 5748