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

int main(){
  int n, d;
  cin >> n >> d;
  if(n%(d*2+1) == 0){
    cout << n/(d*2+1) << endl;
  }
  else{
    cout << n/(d*2+1) + 1 << endl;
  }
}

Measured memory_bytes: 256
# coding: utf-8

import itertools
from functools import reduce
from collections import deque

N, K = list(map(int, input().split(" ")))
A = list(map(int, input().split(" ")))

for i in range(N):
    if i > K-1:
        if A[i] > A[i-K]:
            print("Yes")
        else:
            print("No")


Measured memory_bytes: 32120
#include <iostream> 
#include <cstdlib>
#include <cmath>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++) 

int main() {
    int a, b;
    cin >> a >> b;
    int Counter = 0;

    for (int i = a; i <= b; i++) {
        if (i/10000 == i%10 && i%10000/1000 == i%100/10) {
            Counter += 1;
        }
    }
    cout << Counter << endl;

}



Measured memory_bytes: 256
//                                    ∴In the name of God∴
//                     ✫✗⚡😳😳😄😄😝😝😁😁😎😎😛😛😄😄😮😮⚡✗✫
//                                       H.Pouya  ◠?◠
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<vector>
#include<math.h>
#include<bitset>
#include<iostream>
#include<algorithm>
using namespace std;
typedef short int ss;
typedef long double dd;
typedef long long int ll;
#define give_up return 0;
#define mix(x,y) x*pow(10,y)+10
const int maxn=mix(2,5);
int main()
{
    int n,m,l,r,pl=0,pr=maxn;
    scanf("%d%d",&n,&m);
    while(m--)
    {
        scanf("%d%d",&l,&r);
        pl=max(pl,l);
        pr=min(pr,r);
    }
    printf("%d",max(pr-pl+1,0));
    give_up
}
//  🙄


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/*
 * AtCoder Beginner Contest 103 A "Task Scheduling Problem"
 *   https://abc103.contest.atcoder.jp/tasks/abc103_a/
 */
public class Main {

	public static void main(String[] args) {

		InputScanner in = new InputScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int[] A = in.nextIntArray(3);
		Arrays.sort(A);

		int ans = Math.abs(A[0] - A[1]) + Math.abs(A[1] - A[2]);

		out.println(ans);

		in.close();
		out.close();
	}

	/*
	 * extends java.util.Scanner
	 */
	static class InputScanner {

		Scanner scanner;

		public InputScanner(InputStream inputStream) {
			this.scanner = new Scanner(inputStream);
		}

		public int nextInt() {
			return scanner.nextInt();
		}

		public long nextLong() {
			return scanner.nextLong();
		}

		public double nextDouble() {
			return scanner.nextDouble();
		}
		public String next() {
			return scanner.next();
		}

		public int[] nextIntArray(int n) {
			int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextInt();
			}
			return ret;
		}

		public int[][] nextIntArray(int h, int w) {
			int[][] ret = new int[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextInt();
				}
			}
			return ret;
		}

		public long[] nextLongArray(int n) {
			long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextLong();
			}
			return ret;
		}

		public long[][] nextlongArray(int h, int w) {
			long[][] ret = new long[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public double[] nextDoubleArray(int n) {
			double[] ret = new double[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextDouble();
			}
			return ret;
		}

		public double[][] nextDoubleArray(int h, int w) {
			double[][] ret = new double[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public String[] nextStringArray(int n) {
			String[] ret = new String[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.next();
			}
			return ret;
		}

		public String[] nextStringArray(String split) {
			String[] ret = scanner.next().split(split);
			return ret;
		}

		public String[][] nextStringArray(int h, int w) {
			String[][] ret = new String[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.next();
				}
			}
			return ret;
		}

		public String[][] nextStringArray(int h, String split) {
			String[][] ret = new String[h][];
			for (int i = 0; i < h; i++) {
				ret[i] = scanner.next().split(split);
			}
			return ret;
		}

		public void close() {
			scanner.close();
		}

	}

}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e4 + 10, inf = 0x3f3f3f3f;
int dp[2 * maxn];//health为i + maxn的最小花费
int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    memset(dp, 0x3f, sizeof(dp));
    int h, n;
    cin >> h >> n;
    dp[h + maxn] = 0;
    for (int i = 0; i < n; ++i){
        int v, c;
        cin >> v >> c;
        for (int j = h + maxn; j >= v; --j){
            dp[j - v] = min(dp[j - v], dp[j] + c);
        }
    }
    cout << *min_element(dp, dp + maxn + 1) << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);

#define ull unsigned long long int
#define ll long long int
#define ld double
#define ui unsigned int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second 

#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (long long i = (n) - 1; i >= 0; i--)

void ayush(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

ll gcd(ll a, ll b) 
{ 
    if (a == 0) return b; 
    return gcd(b % a, a); 
} 

ll exp(ll x, ll y, ll p)
{
    ll res = 1;   
    x = x % p;  
    while (y > 0)
    {
        if (y & 1) res = (res*x) % p;
        y = y>>1;     
        x = (x*x) % p; 
    }
    return res;
}
ll mulmod(ll a, ll b, ll mod) 
{ 
    ll res = 0; 
    a = a % mod; 
    while (b > 0) 
    { 
        if (b % 2 == 1) res = (res + a) % mod; 
        a = (a * 2) % mod; 
        b /= 2; 
    }  
    return res % mod; 
} 

int main(){
    ayush();
    fastio;

    ll t; t=1;
    while(t--){
        ll n; cin>>n;
        set<string> st;
        rep(i,n){
            string s; cin>>s;
            st.insert(s);
        }
        cout<<st.size();
    }
    return 0;
}

Measured memory_bytes: 19184
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll n;cin>>n;
    for(;;){
        int r=0;
        for(int i=2;i*i<=n;i++){
            if(n%i==0){
                r=1;
                break;
            }
        }
        if(r==0){
            cout<<n<<endl;
            return 0;
        }
        n++;
    }
}


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

const double EPS = 1e-10;
double b[] = {0.0625, 0.125, 0.25, 0.5};

int main()
{
  double n;
  while (cin >> n) {
    if (n < 0.0)
      break;

    vector<int> digit;
    int d = static_cast<int>(n);
    int dd = d;
    while (dd > 0) {
      digit.push_back(dd%2);
      dd /= 2;
    }
    while (digit.size() < 8)
      digit.push_back(0);

    if (digit.size() > 8) {
      cout << "NA" << endl;
      continue;
    }
    reverse(digit.begin(), digit.end());

    bool found = false;
    for (int i = 0; i < (1 << 4) && !found; ++i) {
      double r = 0.0;
      for (int j = 0; j < 4; ++j) {
	if (i & (1 << j))
	  r += b[j];
      }

      if (abs(d + r - n) < EPS) {
	for (int j = 0; j < 8; ++j)
	  cout << digit[j];
	cout << ".";
	for (int j = 0; j < 4; ++j) {
	  if (i & (1 << (3-j)))
	    cout << "1";
	  else
	    cout << "0";
	}
	cout << endl;
	found = true;
      }
    }

    if (!found)
      cout << "NA" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next(),b = sc.next();
        int count = 0;
        char[] A = a.toCharArray(),B = b.toCharArray();
        for (int i = 0; i <A.length ; i++) {
            if(A[i] == B[i])count++;
        }
        System.out.println(a.length() - count);

    }
}


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

int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string S;
  cin>>S;
  int ans=700;
  for (int i=0; i<3; i++) {
    ans+=S[i]=='o'?100:0;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <climits> // INT_MAX, LONG_MAX, LLONG_MAX, UINT_MAX, ULONG_MAX, ULLONG_MAX
#include <cmath>
#include <cstdint>
#include <cstring> // memset
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#define ALL(x) (x).begin(), (x).end()
#define INF 1e9
#define LOG(x) cout << #x << " = " << (x) << endl
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    string s;
    cin >> s;

    int numW = 0;
    REP(i, n)
        if (s[i] == 'W')
            numW++;

    int numE = n - numW;
    
    int minScore = n;
    int countW = 0;
    int countE = 0;
    
    REP(i, n) {
        int leftW = countW;

        if (s[i] == 'W')
            countW++;
        else
            countE++;

        int rightE = numE - countE;
        minScore = min(minScore, leftW + rightE);
    }

    cout << minScore << endl;
    
    return 0;
}


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

int main() {
  string s; cin >> s;
  int sn = s.size();
  int a1 = 0,a2 = 0;
  rep(i,sn) {
    if ( i    % 2 != s[i] - '0') a1++;
    if ((i+1) % 2 != s[i] - '0') a2++;
  }
  cout << min(a1,a2) << endl;
  return 0;
}

Measured memory_bytes: 3736
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<string> vs;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int n, m;
vvi edges_list;
int dp[101010];

int get_length(int src) {
    if (dp[src] == -1) {
        int max_length = 0;
        for(int dst: edges_list[src]) {
            max_length = max(max_length, get_length(dst));
        }
        dp[src] = max_length + 1;
    }
    return dp[src];
}

int main() {
    cin >> n >> m;
    rep(i, n) {
        vi edges;
        edges_list.pb(edges);
        dp[i] = -1;
    }
    rep(i, m) {
        int in1, in2;
        cin >> in1 >> in2;
        in1--; in2--;
        edges_list[in1].pb(in2);
    }
    vi ans;
    rep(i, n) {
        ans.pb(get_length(i));
    }
    sort(all(ans), greater<int>());
    cout << ans[0] - 1 << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int h,w;
  cin>>h>>w;
  vector<string> a(h);
  REP(i,h)cin>>a[i];
  vector<bool> row(h,false);
  REP(i,h)if(count(ALL(a[i]),'.')==w){
    row[i] = true;
  }
  vector<bool> col(w,true);
  REP(i,h)REP(j,w)if(a[i][j]=='#'){
    col[j] = false;
  }
  REP(i,h){
    if(row[i])continue;
    REP(j,w){
      if(col[j])continue;
      putchar(a[i][j]);
    }
    puts("");
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iostream>
#define maxn 100009
using namespace std;
int n, a[maxn];
long long sum[maxn];
long long solve(int s){
	if(s == 0)
		return 1e18;
	long long ans = abs(a[1] - s);
	if(s < 0){
		long long sum = s;
		int cur = 1;
		for(int i = 2; i <= n; i++){
			if(cur == 1){
				if(sum + a[i] > 0){
					sum += a[i];
				}
				else{
					ans += 1 - (sum + a[i]);
					sum = 1;
				}
			}
			else{
				if(sum + a[i] < 0){
					sum += a[i];
				}
				else{
					ans += sum + a[i] + 1;
					sum = -1;
				}
			}
			cur = -cur;
		}
	}
	else{
		long long sum = s;
		int cur = -1;
		for(int i = 2; i <= n; i++){
			if(cur == 1){
				if(sum + a[i] > 0){
					sum += a[i];
				}
				else{
					ans += 1 - (sum + a[i]);
					sum = 1;
				}
			}
			else{
				if(sum + a[i] < 0){
					sum += a[i];
				}
				else{
					ans += sum + a[i] + 1;
					sum = -1;
				}
			}
			cur = -cur;
		}
	}
	return ans;
}
int main(){
	cin >> n;
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
	}
	long long ans = 1e18;
	ans = min(ans, solve(-1));
	ans = min(ans, solve(1));
	ans = min(ans, solve(a[1]));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
typedef struct{
  int parent;
  int left;
  int right;
} Tree;

Tree tree[1000000];
#define NIL -1
int main()
{
  int i,id,j,n,k,c[100000],depth=0,num;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    tree[i].parent=NIL;
    tree[i].left=NIL;
    tree[i].right=NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&id,&k);
    for(j=0;j<k;j++){
      scanf("%d",&c[j]);
      if(j==0){
	tree[c[0]].parent=id;
        tree[id].left=c[0];
      }
      else{
        tree[c[j]].parent=id;
        tree[c[j-1]].right=c[j];
      }
    }
  }
  
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, ",i,tree[i].parent);
    num=i;
    while(tree[num].parent!=NIL){
      depth++;
      num=tree[num].parent;
    }
    printf("depth = %d,",depth);
    depth=0;
    if(tree[i].parent==NIL && tree[i].left==NIL){
       printf(" root, []\n");
    }
    else if(tree[i].parent==NIL && tree[i].left!=NIL){
      printf(" root, [%d",tree[i].left);
      for(j=tree[tree[i].left].right;j!=NIL;j=tree[j].right){
        printf(", %d",j);
      }
      printf("]\n");
    }
    else if(tree[i].left!=NIL){
      printf(" internal node, [%d",tree[i].left);
      for(j=tree[tree[i].left].right;j!=NIL;j=tree[j].right){
        printf(", %d",j);
      }
      printf("]\n");
    }
    
    else{
      printf(" leaf, []\n");
    }
    
  }
  return 0;
}



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

void roll(char ch, int d[]) {
    int tmp;
    if(ch == 'S'){
        tmp = d[0];
        d[0] = d[4];
        d[4] = d[5];
        d[5] = d[1];
        d[1] = tmp;
    }
    else if(ch == 'W'){
        tmp = d[0];
        d[0] = d[2];
        d[2] = d[5];
        d[5] = d[3];
        d[3] = tmp;
    }
    else if(ch == 'E'){
        tmp = d[0];
        d[0] = d[3];
        d[3] = d[5];
        d[5] = d[2];
        d[2] = tmp;
    }
    else{
        tmp = d[0];
        d[0] = d[1];
        d[1] = d[5];
        d[5] = d[4];
        d[4] = tmp;
    }
}

int find_right(int d[], int front){
    if (d[1] == front) return d[2];
    else if(d[2] == front) return d[4];
    else if (d[3] == front) return d[1];
    else if (d[4] == front) return d[3];
    else return 0;
}

int main() {
    int d[6], n, top, front, right;
    for (int i = 0; i < 6; i++)
        cin >> d[i];
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> top >> front;
        if (d[1] == top)
            roll('N', d);
        else if (d[2] == top)
            roll('W', d);
        else if (d[3] == top)
            roll('E', d);
        else if (d[4] == top)
            roll('S', d);
        else if (d[5] == top){
            roll('N', d);
            roll('N', d);
        }
        else;
        right = find_right(d, front);
        if(right != 0) cout << right << endl;

    }
    return 0;
}





Measured memory_bytes: 3084
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)

ll const INF = 1000000000000000000;
int const I_MAX = 2147483647;
ll const MOD = 1e9 + 7;
int const POW_MAX = 1e5;

// nCr
ll po[POW_MAX + 2];
ll mod_pow(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}
ll mod_inv (ll x) {
  return mod_pow(x, MOD - 2) % MOD;
}
ll comb(int n, int r) {
  return (((po[n] * mod_inv(po[r])) % MOD) * mod_inv(po[n - r])) % MOD;
}
// greatest common divisor
ll gcd(ll a, ll b) {
  while (a % b != 0) {
    ll tmp = a;
    a = b;
    b = tmp % b;
  }
  return b;
}

int const S_MAX = 1e5;
char const B = '0';
char const W = '1';

string S;

int main() {
  cin >> S;

  int len = S.length();

  int even_b = 0;
  int even_all = 0;
  int odd_b = 0;
  int odd_all = 0;
  rep(i, len) {
    char c = S[i];

    if (i % 2 == 0) {
      even_all++;
      if (c == B) even_b++;
    } else {
      if (c == B) odd_b++;
      odd_all++;
    }
  }

  int diff_even = even_all - even_b;
  int diff_odd = odd_all - odd_b;
  int total = min(diff_even + odd_b, diff_odd + even_b);

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


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INF = 1e18;
#define foreach(ix,a) for(auto& (ix) : (a)
typedef long double ld;
const ld eps = 1.0e-10; // 許容される誤差

int main(){
  int n,k;
  map<char,int>point; 
  cin>>n>>k>>point['s']>>point['p']>>point['r'];
  string t;
  cin>>t;
  ll ans =0;
  rep(i,n){
    if(i<k)ans+=point[t[i]];
    else{
      if(t[i]==t[i-k]){
        t[i]='a';
      }
      else
      {
        ans+=point[t[i]];
      }
      
    }
  }
  cout<<ans<<endl;
  
  
}

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> PP;
 
/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/
 
int Q[200010];
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    for (int i = 0;i < N;i++) cin >> Q[i];
    set<int> S;
    ll tol = 0;
    for (int i = N - 1;i >= 0;i--) {
        int t = Q[i];
        if (t == 0) {
            S.insert(i);
            set<int>::iterator it;
            it = S.end();
            it--;
            while (*it > i) {
                S.erase(*it);
                it--;
            }
            S.erase(i);
            if (S.size() > 0) {
                cout << -1 << endl;
                return 0;
            }
            continue;
        }
        int r = i - t;
        if (r < 0) {
            cout << -1 << endl;
            return 0;
        }
        if (S.find(r) == S.end()) tol += t;
        S.insert(r);
        set<int>::iterator it;
        it = S.end();
        it--;
        while (*it > r) {
            S.erase(*it);
            it--;
        }
        if (S.size() > 1) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << tol << endl;
    return 0;
}

Measured memory_bytes: 1148
#include "bits/stdc++.h"
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	int n, i;
	string s;
	cin >> s;
	n = s.size();
	int ans = 0;
	for (i = 0; i < n; i++) {
		if (i < (n + 1) / 2) {
			if (s[i] == 'p') {
				ans--;
			}
		}
		else {
			if (s[i] == 'g') {
				ans++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
//
//  main.cpp

#include <iostream>
#include <stdlib.h>
using namespace std;


int main(){	
	int w,h;
	cin >> w >> h;
	int n;
	cin >> n;
	int matrix[1001][2];
	for(int i=0;i<n;i++){
		cin >> matrix[i][0] >> matrix[i][1];
	}
	
	int answer = 0;
	for(int i=0;i<n-1;i++){
		int x,y;
		x = matrix[i+1][0] - matrix[i][0];
		y = matrix[i+1][1] - matrix[i][1];
		if(x*y < 0){
			answer += abs(x) + abs(y);
		}else{
			answer += min(abs(x),abs(y)) + (max(abs(x),abs(y)) - min(abs(x),abs(y)));
		}
	}
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<ll, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int sy, sx, gy, gx;

int main(){
    int h, w, a, b; cin>>h>>w>>a>>b;
    vector<string> c(h);
    for(int i=0; i<h; i++) cin>>c[i];

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(c[i][j]=='s'){
                sy=i, sx=j;
            }

            if(c[i][j]=='g'){
                gy=i, gx=j;
            }
        }
    }

    priority_queue<T, vector<T>, greater<T>> que;
    que.push(T(0, sy, sx));
    vector<vector<ll>> dist(h, vector<ll>(w, INF));
    dist[sy][sx]=0;
    while(que.size()){
        int cost, cy, cx;
        tie(cost, cy, cx)=que.top(); que.pop();
        //cout << cost << " " << cy << " " << cx << endl;

        if(cy==gy && cx==gx){
            cout << cost << endl;
            return 0;
        }

        for(int i=0; i<4; i++){
            int ny=dy[i]+cy, nx=dx[i]+cx;
            if(0<=ny && ny<h && 0<=nx && nx<w){
                if(c[ny][nx]!='#'){
                    if(cost+a < dist[ny][nx]){
                        dist[ny][nx]=cost+a;
                        que.push(T(cost+a, ny, nx));
                    }
                }
            }
        }

        bool bomb=false;
        for(int i=0; i<9; i++){
            int ny=dy[i]+cy, nx=dx[i]+cx;
            if(0<=ny && ny<h && 0<=nx && nx<w){
                if(c[ny][nx]=='*') bomb=true;
            }
        }

        if(bomb) continue;

        for(int i=0; i<8; i++){
            int ny=dy[i]+cy, nx=dx[i]+cx;
            if(0<=ny && ny<h && 0<=nx && nx<w){
                if(4<=i){
                    if(cost+2*a+b < dist[ny][nx]){
                        dist[ny][nx]=cost+2*a+b;
                        que.push(T(cost+2*a+b, ny, nx));
                    }
                }
                else{
                    if(cost+a+b < dist[ny][nx]){
                        dist[ny][nx]=cost+a+b;
                        que.push(T(cost+a+b, ny, nx));
                    }
                }
            }
        }
    }
    cout << "INF" << endl;
}


Measured memory_bytes: 11700
n = int(input())
A = [0]*10050
 
for x in range(1,105):
    for y in range(1,105):
        for z in range(1,105):
            a = x**2+y**2+z**2+x*y+y*z+z*x
            if a <10050:
                A[a] += 1
                
for i in range(n):
    print(A[i+1])

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

int main() {
    int n, minv, maxv=-2000000000, R; cin >> n >> minv;
    for(int i=1;i<n;i++){
      cin >> R;
      if(maxv<R-minv) maxv=R-minv;
      if(minv>R)minv=R;
    }
    cout << maxv << endl;
    return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define Cout(n) cout<<(n)<<endl
#define INF 1000000000000000000LL

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << ", ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

int main()
{
	ll n,m;
	vll v;
	cin >> n >> m;
	for(ll i=1;i<=sqrt(m);++i){
		if(m%i==0){
			v.pb(i);
			v.pb(m/i);
		}
	}
	sort(all(v));
	rep(i,SIZE(v)){
		if(v[i+1]>(m/n) || i==SIZE(v)-1){
			cout << v[i] << endl;
			break;
		}
	}
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
#include<map>
using namespace std;

#define int long long
#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long

signed main() {
	int N;
	cin >> N;
	
	map<int, int> mp;

	int A;
	REP(i, N) {
		cin >> A;

		if (mp[A] == 0) mp[A] = 1;
		else if (mp[A] == 1) mp[A] = 0;
		else cout << "aaaaa" << endl;
	}
	
	int ans = 0;
	for(pair<int,int> i : mp) {
		//cout << mp[i] << " ";
		if (i.second == 1) ans++;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6528
import math
a, b, h, m = list(map(int, input().split()))
ar = 360 * ((h * 60 + m) / 720)
br = 360 * (m / 60)
r = min(abs(ar - br), 360 - abs(ar - br))
t = math.radians(r)
ans = a * a + b * b - 2 * a * b * math.cos(t)
ans = ans ** (1/2)
print(ans)

Measured memory_bytes: 9516
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			final long D = sc.nextLong();
			
			int answer = 0;
			for(int i = 0; i < N; i++) {
				final long x = sc.nextLong();
				final long y = sc.nextLong();
				
				if(x * x + y * y <= D * D) {
					answer++;
				}
			}
			
			System.out.println(answer);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


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

int main()
{
    int N;
    cin >> N;
    string *s = new string[N];
    for (int i = 0; i < N; ++i)
    {
        cin >> s[i];
    }
    int M;
    cin >> M;
    string *t = new string[M];
    for (int i = 0; i < M; ++i)
    {
        cin >> t[i];
    }
    int ans = 0;
    for (int i = 0; i < N; ++i)
    {
        int plus = count(s, s + N, s[i]);
        int minus = count(t, t + M, s[i]);
        ans = max(ans, plus - minus);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
//author rhythmicankur
                                                                  //god_is_almighty
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#define f 		first
#define s 		second
#define int     long long
#define ll      int
#define ld 		long double
#define pb 		push_back
#define eb 		emplace_back
#define mk 		make_pair
#define vi 		vector<int>
#define pii 		pair<int,int>
#define pip             pair<int,pii>
#define vpi 		vector<pii>
#define sbcount(x) __builtin_popcountll(x)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define trav(a, x)      for(auto& a : x)
#define all(x)          x.begin(), x.end()
#define fill(a,val)	memset(a,val,sizeof(a))
#define 	PI acos(-1)
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define M1 	998244353
#define M2 	1000000007
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); } 
#define test4(x,y,z,a) 		    cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"  |  "<<#a<<": "<<a<<endl;
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
ll power(ll a,ll b,ll m=M2){ll answer=1;while(b){if(b&1)answer=(answer*a)%m;b/=2;a=(a*a)%m;}return answer;}
using namespace std;
void ctrl(){cout<<"Control"<<endl;}
int make_num(string p){stringstream geek(p); int x = 0; geek >> x;return x;}
string make_str(int x){ostringstream str1; str1 << x; string geek = str1.str(); return geek;}

signed main()
{	ios::sync_with_stdio(0);
	cin.tie(0); 
	cin.exceptions(cin.failbit);
	int n;
    cin>>n;
    unordered_map<string,int>mp;
    for(int i=0;i<n;i++)
    {
        string h;
        cin>>h;
        mp[h]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"];


return 0;
}

Measured memory_bytes: 3672
use std::collections::HashSet;
use std::io::stdin;
use std::process;

fn kenken(
    s: usize,
    ts: &Vec<Vec<usize>>,
    d: &mut Vec<usize>,
    count: usize,
    dest: &mut Vec<usize>,
    v1: &mut HashSet<usize>,
    v2: &mut HashSet<usize>,
    v3: &mut HashSet<usize>,
) {
    if v1.contains(&s) {
        return;
    }
    v1.insert(s);
    for t1 in &ts[s] {
        if v2.contains(&*t1) {
            continue;
        }
        v2.insert(*t1);
        for t2 in &ts[*t1] {
            if v3.contains(&*t2) {
                continue;
            }
            v3.insert(*t2);
            for t3 in &ts[*t2] {
                if d[*t3] == 0 {
                    d[*t3] = count;
                    dest.push(*t3);
                }
            }
        }
    }
}

fn main() {
    let mut ss = String::new();
    stdin().read_line(&mut ss).ok();
    let n: usize;
    let m: usize;
    let s: usize;
    let t: usize;
    let v: Vec<usize> = ss
        .trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect();
    n = v[0];
    m = v[1];
    let mut uv: Vec<Vec<usize>> = Vec::new();
    for _i in 0..m {
        ss = String::from("");
        stdin().read_line(&mut ss).ok();
        uv.push(
            ss.trim()
                .split_whitespace()
                .map(|e| e.parse().ok().unwrap())
                .collect(),
        );
    }
    ss = String::from("");
    stdin().read_line(&mut ss).ok();
    let v: Vec<usize> = ss
        .trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect();
    s = v[0];
    t = v[1];
    let mut d: Vec<usize> = Vec::new();
    let mut ts: Vec<Vec<usize>> = Vec::new();
    for _i in 0..(n + 1) {
        d.push(0);
        ts.push(vec![]);
    }
    for e in uv {
        let u = e[0];
        let v = e[1];
        ts[u].push(v);
    }
    let mut count = 1;
    let mut dest: Vec<usize> = vec![s];
    let mut v1 = HashSet::new();
    let mut v2 = HashSet::new();
    let mut v3 = HashSet::new();
    loop {
        if dest.len() == 0 {
            break;
        }

        let mut ndest: Vec<usize> = Vec::new();
        for ss in dest {
            kenken(
                ss, &ts, &mut d, count, &mut ndest, &mut v1, &mut v2, &mut v3,
            );
        }
        if d[t] > 0 {
            println!("{}", d[t]);
            process::exit(0);
        }
        count += 1;
        dest = ndest;
    }
    println!("-1");
}


Measured memory_bytes: 22160
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

a, b, c = mi()
d, e, f = mi()
g, h, i = mi()

print('Yes' if g-d == h-e and h-e==i-f and d-a == e-b and e-b == f-c and g-a==h-b and h-b==i-c and a-b == d-e and d-e == g-h and b-c == e-f and e-f == h-i and a-c == d-f and d-f == g-i else 'No')



Measured memory_bytes: 38480
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 5e6 + 3;
ll i,n;
string b;
long double a,s;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n;
    rep(i,0,n){
        cin>>a>>b;
        if(b == "BTC")
            a *= 380000.0;
        s += a;
    }
    cout<<setprecision(7)<<fixed<<s;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
#define rep2(x,from,to) for(int x=from;x<to;x++)
#define rep(x,to) rep2(x,0,to)
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P>  PP;
typedef pair<int,PP> PPP;
int n;
int k;
int h;
int ans;
int main()
{
    cin>>n>>k;
    rep(i,n)
    {
        cin>>h;
        if(h>=k)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int N;
    cin >> N;
    int A;
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        cin >> A;
        while (A % 2 == 0) {
            ans++;
            A /= 2;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {

			int n = sc.nextInt();
			int k = sc.nextInt();
			int[] h = new int[n];
			for(int i = 0 ; i < n ; i++) {
				h[i] = sc.nextInt();
			}
			int[] dp = new int[n];
			for(int i = 0 ; i < n ; i++) {
				if(i == 0) {
					dp[i] = 0;
				} else {
					int minCost = Integer.MAX_VALUE;
					int minCnt = Math.min(k, i);
					for(int j = 1 ; j <= minCnt ; j++) {
						int cost = dp[i - j] + Math.abs(h[i - j] - h[i]);
						minCost = Math.min(minCost, cost);
					}
					dp[i] = minCost;
				}
			}
			System.out.println(dp[n - 1]);

		}
	}
}


Measured memory_bytes: 51724
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <utility>
#include <cmath>
#include <functional>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
#define iter(it,v) for(auto it=v.begin();it!=v.end();++it)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"
// #define in(v) if (scanf("%d", &v)<1);
// #define out(v) printf("%d\n", v)
const int MOD = 1e9+7;
const int INF = numeric_limits<int>::max();
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; }

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

  int x = 0;
  rep(i, 100000000) {
    x += i;
    if (x >= X) {
      out(i);
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
A, B = map(int, input().split())


def xor(x):
    if x % 4 == 0:
        return x
    elif x % 4 == 1:
        return 1
    elif x % 4 == 2:
        return 1 ^ x
    else:
        return 0


print(xor(A-1) ^ xor(B))

Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

int p[2 * 100000];

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

    int N;
    cin >> N;

    int P;
    rep (i, N)
    {
        cin >> P;
        p[P - 1] = i;
    }

    int ans = 1;
    int previ = 0;
    for (int i = 0; i < N - 1; ++i)
    {
        while (i < N - 1 && p[i] < p[i + 1]) ++i;
        ans = MAX(i - previ + 1, ans);
        previ = i + 1;
    }

    cout << N - ans << "\n";

    return 0;
}



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

typedef long long ll;

int main(){
  int N,M;
  cin >> N >> M;
  map<int,bool> m1, m2; // 1とつながるところ、2とつながるところ
  
  for(int i = 0; i < M; i++){
    int tmp1, tmp2;
    cin >> tmp1 >> tmp2;
    if(tmp1 == 1){
      m1[tmp2] = true;
    }
    if(tmp2 == N){
      m2[tmp1] = true;
    }
  }
  bool flg = false;
  for(auto x : m1){
    if(m2.count(x.first) > 0){
      flg = true;
      break;
    }
  }
  if(flg){
    cout << "POSSIBLE" << endl;
  } else { 
    cout << "IMPOSSIBLE" << endl;
  }
  
  
}

Measured memory_bytes: 9600
#include <iostream>
#include<algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)

using namespace std;



int main() {
    int p,q,r;
    cin>>p>>q>>r;
    int min_time=min(p+q,min(q+r,r+p));
    cout<<min_time<<endl;

    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
    int n; cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    if(n >= 24){
        cout << 0 << endl;
        return 0;
    }
    vector<int> cnt(25);
    if(n == 23){
        rep(i,n) cnt[d[i]]++;
        if(cnt[12] >= 2){
            cout << 0 << endl;
            return 0;
        }
        bool ok = false;
        rep(i,n){
            if(cnt[i] >= 3) ok = true;
        }
        cout << (ok?0:1) << endl;
        return 0;
    }
    int ans = 0;
    rep(i,1<<n){
        vector<int> v;
        rep(j,n){
            if(i>>j&1){
                v.push_back(d[j]);
            }
            else v.push_back(24-d[j]);
        }
        sort(v.begin(),v.end());
        int now = v[0];
        rep(i,n-1) now = min(now,v[i+1]-v[i]);
        now = min(now,24-v[(int)v.size()-1]);
        ans = max(ans,now);
    }
    cout << ans << endl;
} 




Measured memory_bytes: 3640
N = int(input())
A = list(map(int, input().split()))
A = sorted(A,reverse=True)
B = 1
if 0 in A:
    print(0)
    quit()
else:
    for i in A:
        B *= i
        if B> 10**18:  
            print(-1)
            quit()
print(B)

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

string s;
int64_t a[100002], k;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin>>s;
  int64_t n = s.size();
  for (int i = 0; i < n; i++) {
    if (s[i]=='R') k=i;
    else a[k + (i-k)%2]++;
  }
  for (int i = n-1; i >= 0; i--) {
    if (s[i]=='L') k = i;
    else a[k - (k-i)%2]++;
  }

  for (int i = 0; i < n; i++) {
    cout<<a[i]<<" ";
  }
  cout << '\n';
}


Measured memory_bytes: 1488
num = input()

x = ["+", "-"]

for i in x:
  for j in x:
    for k in x:
      n = eval(num[0]+i+num[1]+j+num[2]+k+num[3])
      if n == 7:
        print(num[0]+i+num[1]+j+num[2]+k+num[3]+"=7")
        exit()

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

const int N = 2 * 1e5 + 10;
const int mod = 1e9 + 7;
using namespace std;

int n;
int quick_pow(int a, int b)
{
	int res = 1;
	while(b)
	{
		if(b&1)
		{
			res = 1ll * res * a % mod;
		}
	   	b >>= 1;
	   	a = 1ll*a*a%mod;
	}
	return res;
}
struct edge
{
	int y;
	int next;
}ed[2*N];
int en = 0;
int head[N];
void add_edge(int x, int y)
{
	en++;
	ed[en].y = y;
	ed[en].next = head[x];
	head[x] = en;
}
int f[N];
void dfs(int u, int fa)
{
	for(int p = head[u]; p != 0; p = ed[p].next)
	{
		int v = ed[p].y;
		if(v == fa)continue; 
			dfs(v, u);
			f[u] += f[v];
	}
	f[u]++;
}
int ans[N];
void move(int u, int fa)
{
	for(int p = head[u]; p != 0; p = ed[p].next)
	{
		int v = ed[p].y;
		if(v == fa)
		{
			continue;
		}
		ans[v] =  1ll * ans[u] * quick_pow(f[v], mod-2) % mod * (n - f[v]) % mod;
		move(v, u);
	}

}
int main()
{
	cin >> n;
	for(int i = 1; i <= n-1; i++)
	{
		int a, b;
		cin >> a >> b;
		add_edge(a, b);
		add_edge(b, a);
	}
	dfs(1, 0);
	ans[1] = 1;
	for(int i = 1; i <= n; i++)
	{
		ans[1] = 1ll * ans[1] * f[i] % mod;
	}
	move(1, 0);
	int t = 1;
	for(int i = 1; i <= n; i++)
	{
		t = 1ll * i * t % mod;
	}
	for(int i = 1; i <= n; i++)
	{
		printf("%d\n", 1ll * t * quick_pow(ans[i], mod-2) % mod);
	}
	return 0;
}


Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  int r,d,x;cin>>r>>d>>x;
  for(int i=1;i<=10;i++){
    x=r*x-d;
    cout<<x<<endl;
  }

  
  return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
   int n;
   cin >> n;
   vi a(n);
   rep(i,n) cin >> a[i];
   vi b(100002);
   for(int i = 0; i < n; i++) {
       b[a[i]] += 1;
       b[a[i] + 1] += 1;
       b[a[i] + 2] += 1;
   } 
    sort(b.rbegin(),b.rend());
    cout << b[0] << endl;
}

Measured memory_bytes: 1024