akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define RREP(i,a) for(int (i)=(a)-1;(i)>=0;(i)--)
#define FORR(i,a,b) for(int (i)=(a)-1;(i)>=(b);(i)--)
#define PI acos(-1.0)
#define DEBUG(C) cout<<C<<endl;
#define VI vector<int>
#define VII vector<VI>
#define VL vector<LL>
#define VLL vector<VL>
#define VD vector<double>
#define VDD vector<VD>
#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<LL,LL>
#define VPII vector<PII>
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define REVERSE(a) reverse(ALL(a))
#define MP make_pair
#define EP emplace_back
#define FORE(a,b) for(auto &&a:b)

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int INF=1e9;
const int MOD=INF+7;
#define int LL

signed main(){
    int N; cin >> N;
    VL A(N);
    REP(i,N){
        scanf("%lld",&A[i]);
    }
    VL dp(N,0);
    dp[0]=A[0]/2;
    A[0]-=(dp[0]*2);
    FOR(i,1,N){
        if(A[i]&&A[i-1]){
            A[i]--;A[i-1]--;
            dp[i]++;
        }
        int buf=A[i]/2;
        A[i]-=(buf*2);
        dp[i]+=dp[i-1]+buf;
    }
    cout<<dp.back()<<endl;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	while(true){
		int h,w; cin>>h>>w;
		if(h==0&&w==0)break;
		for(int i=0;i<h;++i){
			for(int j=0;j<w;++j){
				if(i==0||i==h-1||j==0||j==w-1)cout<<'#';
				else cout<<'.';
			}
			cout<<"\n"s;
		}
		cout<<"\n"s;
	}
}


Measured memory_bytes: 3104
import java.util.*;
import java.io.*;
 
public class Main{
    public static void main(String[] args){
        Main m = new Main();
        m.input();
    }
 
    public void input(){
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        char[][] map = new char[h][w];
        for(int i = 0; i < h; i++){
            String s = sc.next();
            for(int j = 0; j < w; j++){
                map[i][j] = s.charAt(j);
            }
        }
        sc.close();
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(map[i][j] == '#'){
                    if(!check(map, h, w, i, j)){
                        System.out.println("No");
                        return;
                    }
                }
            }
        }
        
        System.out.println("Yes");
    }

    int[] x = {0, 1, 0, -1};
    int[] y = {-1, 0, 1, 0};
    public boolean check(char[][] map, int h, int w, int nowx, int nowy){
        for(int i = 0; i < 4; i++){
            if(nowx + x[i] >= h || nowx + x[i] < 0){
                continue;
            }
            if(nowy + y[i] >= w || nowy + y[i] < 0){
                continue;
            }
            if(map[nowx + x[i]][nowy + y[i]] == '#'){
                return true;
            }
        }

        return false;
    }
    
}

Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

vector<vector<vector<int>>> dp(105, vector<vector<int>>(105, vector<int>(350, -1)));

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

    int n, W;
    cin >> n >> W;
    vector<int> w(n), v(n);
    int base;
    cin >> base >> v[0];
    w[0] = 0;
    for(int i = 1; i < n; ++i){
        cin >> w[i] >> v[i];
        w[i] -= base;
    }
    dp[0][0][0] = 0;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j <= n; ++j){
            for(int k = 0; k <= 300; ++k){
                if(dp[i][j][k] == -1)   continue;
                chmax(dp[i + 1][j][k], dp[i][j][k]);
                chmax(dp[i + 1][j + 1][k + w[i]], dp[i][j][k] + v[i]);
            }
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; ++i){
        for(int j = 0; j <= 300; ++j){
            if(dp[n][i][j] == -1)   continue;
            ll weight = (ll)base * i + j;
            if(weight <= W) chmax(ans, dp[n][i][j]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 15872
N, M = map(int, input().split())
A = list(map(int, input().split()))
sumA, d = 0, {0: 1}
for i in range(N):
    sumA = (sumA + A[i]) % M
    if sumA in d:
        d[sumA] += 1
    else:
        d[sumA] = 1

ans = 0
for v in d.values():
    ans += v * (v - 1) // 2

print(ans)


Measured memory_bytes: 15020
#include<stdio.h>
#include<string.h>
int main(void){
  int i;
  char a[100],b[100];
  scanf("%s %s", a, b);
  for( i=0; i<strlen(a); i++){
    if(a[i]!=b[i]){
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}


Measured memory_bytes: 1640
d=[int(input()) for i in range(5)]
d2=[]
d_mod=[]
for j in d:
  if j%10 != 0:
    add=10-j%10
    j=j+10-j%10
  else:
    add=0
  d_mod.append(add)
  d2.append(j)
print(sum(d2)-max(d_mod))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

// ref: https://codeforces.com/blog/entry/62393

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = 1e5 + 5;
gp_hash_table<int, int, custom_hash> cnt;

const bool fast_io = []() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
  return true;
};

int main() {
	int n; cin >> n;
	vector<int> v(n);

	for (auto& iter : v) {
		cin >> iter;
	}
	int cur = 0;
	for (auto it : v) {
		cur = __gcd(cur, it);
		cnt[it]++;
	}
	if (cur > 1) {
		// linear gcd is not 1 
		// not coprime
		return cout << "not coprime" << endl, 0;
	}
	int mx = *max_element(v.begin(), v.end());
	for (int i = 2; i <= mx; i++) {
		int total = 0;
		for (int j = i; j <= mx; j += i) {
			total += cnt[j];
		}
		if (total > 1) {
			return cout << "setwise coprime" << endl, 0;
		}
	}
	cout << "pairwise coprime" << endl;
}

Measured memory_bytes: 44252
#include <stdio.h>

int main(int argc, const char * argv[])
{
    int i, j;
    for (i = 1; i < 10; i++) {
        for (j = 1; j < 10; j++) {
            printf("%dx%d=%d\n", i, j, i*j);
        }
    }
    
    return 0;
}

Measured memory_bytes: 524
from math import floor, sqrt, ceil


def f(b, n):
    if b < 2:
        return 0

    if n < b:
        return n

    return f(b, floor(n / b)) + n % b


n = int(input())
s = int(input())

if n == s:
    print(n + 1)
    exit()

for b in range(2, floor(sqrt(n)) + 1):
    if f(b, n) == s:
        print(b)
        exit()

for p in range(1, ceil(sqrt(n)))[::-1]:
    b = (n - s) / p + 1
    if b.is_integer():
        b = int(b)
        if 1 <= p < b and 0 <= s - p < b:
            print(b)
            exit()

print(-1)


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

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr int mo2 = 998244353;
constexpr ll infl = 1ll<<60;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin>>n;
    string s;
    cin>>s;
    ll ret = 0ll;
    for(int i=0;i<=9;++i){
        for(int j=0;j<=9;j++){
            for(int k=0;k<=9;++k){
                int cur =0;
                while(cur < n and s[cur]-'0'!= i)cur++;
                cur++;
                while(cur < n and s[cur]-'0' != j)cur++;
                cur++;
                while(cur < n and s[cur]-'0' != k)cur++;
                if(cur < n)ret++;
            }
        }
    }
    cout << ret << endl;
    return 0;
}



Measured memory_bytes: 384
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 11451419198109130;
typedef pair<int, int> P;
typedef pair<int, P> PP;
struct edge { int to; int to2; int cost; };
string s[405];
int dp[405][405];
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 };
int h, w;
int b[160005], W[160005];
int par[160005], rnk[160005];
void init(int n) {
	rep(i, n) {
		par[i] = i; rnk[i] = 0;
	}
}
int find(int x) {
	if (par[x] == x)return x;
	return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rnk[x] < rnk[y])par[x] = y;
	else {
		par[y] = x;
		if (rnk[x] == rnk[y])rnk[x]++;
	}
}

signed main() {
	cin >> h >> w;
	rep(i, h) {
		cin >> s[i];
	}
	int sum = 0;
	init(160004);
	rep(i, h) {
		rep(j, w) {
			rep(k, 4) {
				int ni = i + dx[k], nj = j + dy[k];
				if (0 <= ni&&ni < h && 0 <= nj&&nj < w&&s[i][j] != s[ni][nj]) {
					unite(ni*w + nj, i*w + j);
				}
			}
		}
	}

	rep(i, h) {
		rep(j, w) {
			if (s[i][j] == '#')b[find(i*w + j)]++;
			else W[find(i*w + j)]++;
		}
	}
	rep(i, h*w)sum += b[i] * W[i];
	cout << sum << endl;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;

typedef long long LL;
typedef long double ldouble;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    string s, t;
    cin >> s >> t;
    for(int i = 0; i < s.size(); ++i) {
        if(i == t.size()) {
            cout << char(s[i]);

        } else {
            cout << char(s[i]) << char(t[i]);

        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
import math

n = int(input())
count = 0
for i in range(1, n+1, 2):
    lst = [0] * 20
    for j in range(2, int(math.sqrt(i))+1):
        if i % j == 0:
            lst[j] += 1
    a = 1
    for k in lst:
        a *= (k+1)
    if a == 8:
        count += 1

print(count)

Measured memory_bytes: 3060
n,m = map(int,raw_input().split())
q = map(int,raw_input().split())

q.sort()

data = []

for a in range(1,len(q)):
  data.append( q[a] - q[a-1] )

data.sort()

for a in range( n-1 ):
 try:
  data.pop()
 except:
  pass

ans = 0

for a in range( len(data) ):
  ans += data[a]

print ans


Measured memory_bytes: 11252
import heapq

n, m = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a)  # aを優先度付きキューに

for _ in range(m):
    tmp_min = heapq.heappop(a)
    heapq.heappush(a, (-1)*(-tmp_min//2))  # 負数の剰余演算を避けるため一時的に0以上の整数にしています
print(-sum(a))

Measured memory_bytes: 20484
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e9
typedef long long ll;
typedef pair<ll,ll> P;


int main(void){
    ll x;
    cin>>x;
    ll t=1;
    while(true){
        if(t*(t+1)>=2*x){
            cout<<t<<endl;
            return 0;
        }
        else{
            t++;
        }
    }
    return 0;
}

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

long long N;
long long W[105];

int main(){
	cin >> N;
	long long sum = 0;
	for(long long i = 0; i < N; i++){
		cin >> W[i];
		sum += W[i];
	}

	long long ans = sum;
	long long cur = 0;
	for(long long i = 0; i < N; i++){
		cur += W[i];
		ans = min(ans, abs(sum - 2*cur));
	}

	cout << ans << endl;
}


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

ll gcd(ll a, ll b) {
  if(a==0) return b;
  if(a>b) return gcd(a%b, b);
  else return gcd(b%a, a);
}
ll lcm(ll a, ll b) {
  return a*b/gcd(a,b);
}

int main() {
  ll n,x;
  cin >> n >> x;
  vector<ll> a(n);
  for(int i=0;i<n;i++) {
    cin >> a[i];
  }
  sort(a.begin(),a.end());

  ll ans=0,num=0;
  while(1) {
    ans += a[num];
    if(ans>x) {
      break;
    }
    num++;
    if(ans==x) {
      break;
    }
    if(num == n) {
      num--;
      break;
    }
  }
  cout << num << endl;
}

Measured memory_bytes: 256
from collections import deque
dq = deque([1,2,3,4,5,6,7,8,9])
ans = []
while dq:
    p = dq.popleft()
    ans.append(p)
    if p <= 323456666:
        q = p % 10
        if not q in [0,9]:
            for i in range(-1,2):
                dq.append(10*p+q+i)
        else:
            if q == 9:
                dq.append(10*p+8)
                dq.append(10*p+9)
            else:
                dq.append(10*p)
                dq.append(10*p+1)
ans.sort()
#print(ans)
print(ans[int(input())-1])

Measured memory_bytes: 13996
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

int dp[3000][3000];
char x[3000][3000]; //! 0: came from left, 1: came from top, 2: add new char to top left


int main()
{
    string s, t;
    cin >> s >> t;

    string EMPTY;

    for (int i = 0; i < s.length(); ++i) {
        for (int j = 0; j < t.length(); ++j) {
            int left = (j == 0) ? 0 : dp[i][j-1];
            int top = (i == 0) ? 0 : dp[i-1][j];
            int topLeft = (i == 0 || j == 0) ? 0 : dp[i-1][j-1];
            if (s[i] == t[j]) {
                dp[i][j] = topLeft + 1;
                x[i][j] = 2;
            } else if (left < top) {
                dp[i][j] = top;
                x[i][j] = 1;
            } else {
                dp[i][j] = left;
                x[i][j] = 0;
            }
        }
    }

    string ans;
    int i = s.length()-1;
    int j = t.length()-1;
    while (ans.length() < dp[s.length()-1][t.length()-1]) {
        switch (x[i][j]) {
            case 2:
                ans = s[i] + ans;
                --i;
                --j;
            break;
            case 1:
                --i;
            break;
            case 0:
            default:
                --j;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


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

void prians(bool answer) {
  if(answer)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
string w;
int cnt[26] = {0};
bool ch = 1;

int main() {
  cin >> w;
  for(int i = 0; i < w.size(); ++i) ++cnt[w[i] - 'a'];
  for(int i = 0; i < 26; ++i)
    if(cnt[i] % 2 == 1) ch = 0;
  prians(ch);
  return 0;
}

Measured memory_bytes: 256
table={"I"=>1,"V"=>5,"X"=>10,"L"=>50,"C"=>100,"D"=>500,"M"=>1000}
while s=STDIN.gets
    sum=0
    s=s.chomp
    for i in 0..s.length-1 do
        if i < s.length-1 and table[s[i]] < table[s[i+1]] then
            sum = sum - table[s[i]] 
        else
            sum = sum + table[s[i]]
        end
    end
    print sum,"\n"
end

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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    ll a, b;
    string s;
    cin >> a >> b;
    cin >> s;
    ll cnt_num = 0, cnt_bar = 0;
    REP(i, a + b + 1)
    {
        if (s[i] == '-')
        {
            cnt_bar++;
        }
        else
        {
            cnt_num++;
        }
    }
    if (cnt_num == a + b && cnt_bar == 1 && s[a] == '-')
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    vector <int> v(n);
    generate(all(v),nxt);
    sort(v.begin(),v.end());
    vector <int> v2;
    int i=0;
    while(i<n)
    {
        int x=i;
        while(i<n&&v[x]==v[i])
            i++;
        v2.push_back(i-x);
    }
    sort(v2.begin(),v2.end());
    int m=v2.size();
    vector <int> prefix(m);
    prefix[0]=v2[0];
    for(int i=1;i<m;i++)
        prefix[i]=prefix[i-1]+v2[i];
    vector <int> v3(n+1);
    for(int k=1;k<=n;k++)
    {//cout<<"came\n";
        int l=0,r=m-1;
        int test=m;
        while(l<=r)
        {
            int mid=(l+r)/2;
            if(v2[mid]>=k)
            {
                test=mid;
                r=mid-1;
            }
            else
                l=mid+1;
        }
        v3[k]=m-test;
        if(test-1>=0)
            v3[k]+=(prefix[test-1]/k);
    }
    for(int i=1;i<=n;i++)
    {
        int ans=0;
        int l=1,r=n;
        while(l<=r)
        {
            int mid=(l+r)/2;
            if(v3[mid]>=i)
            {
                ans=mid;
                l=mid+1;
            }
            else
                r=mid-1;
        }
        cout<<ans<<endl;
    }
    
    return 0;   
}


 
 


Measured memory_bytes: 5488
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(long long i=0;i<n;i++)
#define REPP(i,m,n) for(long long i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int A,B;
int cnt = 0;
int ans = 1;
int solve(){
    if(B <= (ans-1)+A){
        cnt++;
        return cnt;
    }
    else{
      	cnt++;
        ans = (ans-1)+A;
      	solve();
    }
}
int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    cin >> A >> B;
    if(B == 1){
        cout << 0 << endl;
        return 0;
    }
    int C = solve();
    cout << C << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(  )
{
	char b;
	cin>>b;
	if(b=='A'){
		cout<<"T"<<endl;
	}
	else if(b=='T'){
		cout<<"A"<<endl;
	}
	else if(b=='C'){
		cout<<"G"<<endl;
	}
	else
		cout<<"C"<<endl;
	
	return 0;
}


Measured memory_bytes: 256
using System;
using static System.Console;

namespace abc167
{
    class Program
    {
        const int keyNum = 998244353;
        static void Main()
        {
            var nmk = ReadLine().Split(' ');
            var n = int.Parse(nmk[0]);
            var m = int.Parse(nmk[1]);
            var k = int.Parse(nmk[2]);

            WriteLine(CB(n, m, k));
        }
        static int CB(int n, int m, int k)
        {
            if (m == 1)
            {
                if (k == n - 1)
                {
                    return 1;
                }
                else
                {
                    return 0;
                }
            }
            int[] facts = null;
            int[] revFacts = null;
            GetFactorialsDiv(n, keyNum, out facts, out revFacts);

            var total = 0L;
            for (var i = 0; i <= k; ++i)
            {
                var subTotal = ((long)NCRDiv(n - 1, i, facts, revFacts, keyNum) * m) % keyNum;
                subTotal = (subTotal * Exp(m - 1, n - i - 1, keyNum)) % keyNum;
                total = (total + subTotal) % keyNum;
            }
            return (int)total;
        }

        static void GetFactorialsDiv(int n, int keyNum, out int[] facts, out int[] revFacts)
        {
            facts = new int[n + 1];
            revFacts = new int[n + 1];

            facts[0] = 1;
            var tmp = 1L;
            for (var i = 1; i <= n; ++i)
            {
                tmp = (tmp * i) % keyNum;
                facts[i] = (int)tmp;
            }
            // n!^-1 = n!^(m-2) (mod m)
            tmp = Exp(facts[n], keyNum - 2, keyNum);
            revFacts[n] = (int)tmp;
            for (var i = n; i > 1; --i)
            {
                tmp = (tmp * i) % keyNum;
                revFacts[i - 1] = (int)tmp;
            }
        }
        static long Exp(int n, int k, int keyNum)
        {
            if (k == 0)
            {
                return 1;
            }
            if (k == 1)
            {
                return n;
            }
            var half = Exp(n, k / 2, keyNum);
            var result = (half * half) % keyNum;
            return ((k % 2) == 0) ? result : ((result * n) % keyNum);
        }
        static int NCRDiv(int n, int r, int[] facts, int[] revFacts, int keyNum)
        {
            if (r == 0 || r == n)
            {
                return 1;
            }
            if (r == 1)
            {
                return n;
            }
            var result = 1L;
            result = (result * facts[n]) % keyNum;
            result = (result * revFacts[r]) % keyNum;
            result = (result * revFacts[n - r]) % keyNum;
            return (int)result;
        }
    }
}


Measured memory_bytes: 28820
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int main() {
  int N;
  int a[2000];
  cin >> N;
  rep(i, N) {
    cin >> a[i];
  }
  sort(a, a+N);
  vector<pair<int, P>> b;
  // int b[2000][2000];
  rep(i, N) {
    for(int j = i + 1; j < N; j++) {
      b.push_back({a[j]-a[i], {i, j}});
      // b[i][j] = a[j] - a[i];
    }
  }

  int ans = 0;

  rep(i, b.size()) {
    int key = b[i].first;
    int ni = b[i].second.first;
    int nj = b[i].second.second;
    int ind = upper_bound(a+ni+1, a+nj, key) - a;
    int temp = nj - ind;
    ans += temp;
  }

  cout << ans << endl;

  return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

const ll MOD = 998244353;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s; cin >> s;
	ll k; cin >> k;
	
	vl a;
	ll cur = 0;
	for (char c: s) {
		if (c == '0') a.pb(cur), cur = 0;
		else cur++;
	}
	a.pb(cur);
	reverse(all(a));

	ll sum = 0;
	vvl dp = {{1}}; // dp[given][rem], 0 <= rem <= given <= sum

	for (ll x: a) {
		ll nsum = min(sum+x,k);
		vvl ndp(nsum+1, vl(2*nsum+1));

		FOR(given,0,sum+1) FOR(rem,0,given+1) if (dp[given][rem]) {
			FOR(here,-rem,x+1) {
				ll ngiven = given + max(here,0LL);
				if (ngiven > k) continue;
				ll nrem = rem + here;
				ndp[ngiven][nrem] += dp[given][rem];
			}
		}

		dp = ndp, sum = nsum;

		FOR(given,0,sum+1) FOR(rem,0,given+1) dp[given][rem] %= MOD;
	}
	
	ll res = 0;
	FOR(given,0,sum+1) res += dp[given][0];
	res %= MOD;
	cout << res << endl;
}



Measured memory_bytes: 6304
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0;i < n;i++) {
			a[i] = sc.nextInt();
		}
		int min = a[0];
		int max = a[0];
		for(int i = 1;i<n;i++) {
			if(min > a[i]) {
				min = a[i];
			}
			if(max < a[i]) {
				max = a[i];
			}
		}
		System.out.println(max-min);
	}

}


Measured memory_bytes: 21460
from sys import stdin
from sys import setrecursionlimit
from collections import Counter, deque, defaultdict
from bisect import bisect_left
setrecursionlimit(1000000)

INF = int(1e10)
MOD = int(1e9 + 7)

def input():
    return stdin.readline()[:-1]


def main():
    from builtins import int, map
    n = int(input())
    count = defaultdict(int)
    for _ in range(n):
        s = input()
        count[s] += 1
    print(len(count))


if __name__ == '__main__':
    main()

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

int main(){
  int a,b;
  cin>>a>>b;
  if(a<=8 && b<=8){
    cout<<"Yay!"<<endl;
    return 0;
  }
  cout<<":("<<endl;
  
  
  
  
  return 0;
}

       
       

Measured memory_bytes: 3584
#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>

using namespace std;
using Int = long long;
typedef pair<int,int> Pi; typedef pair<Int,Int> Pl;
constexpr int mod = 1e9+7;
constexpr int INF32 = numeric_limits<int>::max();
constexpr Int INF64 = numeric_limits<Int>::max();
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rer(i,l,r) for(int(i)=(l); (i)<(r); ++(i))
#define rep(i,n) rer(i,0,n)
#define gnr(i,l,r) for(int (i)=(r)-1; (i)>=(l); --(i))
#define pri(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(i,n-1)cout<<a[i]<<' '; if(n)cout<<a[n-1]<<'\n';}
#define prip(p) cout<<(p).fi<<' '<<(p).se<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,m,_,x,y,q;
string s,sb;
bool ok;
char cf,cb;

int main(){
  cin.tie(nullptr); ios::sync_with_stdio(0);
  //cout<<fixed<<setprecision(20);
  
  while(cin>>s){
    cin>>sb; pri(to_string(stoi(s)+stoi(sb)).size());
  }
}


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

using namespace std;
#define ll long long


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

    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];

    int q;
    cin >> q;

    int b, m, e;
    for (int i = 0; i < q; i++) {
        cin >> b >> m >> e;
        rotate(a + b, a + m, a + e);
    }

    for (int i = 0; i < n; i++) cout << a[i] << " \n"[i == n - 1];

    return 0;
}


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

using namespace std;
using ll = long long;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++i)
#define FORR(i,L) for(auto& (i):(L))
#define ALL(a) ((a).begin()),((a).end())

int N;
ll S[1<<18];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,1<<N) cin>>S[i];
	sort(S,S+(1<<N));
	multiset<int> T;
	FOR(i,(1<<N)-1) T.insert(S[i]);
	
	vector<int> V;
	V.push_back(S[(1<<N)-1]);
	FOR(i,N) {
		vector<int> W=V;
		
		FORR(v,V) {
			auto it=T.lower_bound(v);
			if(it==T.begin()) return _P("No\n");
			it--;
			W.push_back(*it);
			T.erase(it);
		}
		
		sort(ALL(W));
		reverse(ALL(W));
		swap(V,W);
	}
	_P("Yes\n");
	
}

int main()
{
    solve();

    return 0;
}

Measured memory_bytes: 14592
import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Map;
import java.util.HashMap;

public class Main
{
    long a, b, x;
    
    public static void main(String args[])
    {
	new Main().solve();
    }
    
    void solve()
    {
	in();

	long cnt = b / x;
	if(a == 0) cnt++;
	else       cnt -= (a - 1) / x;
	
	out(cnt);
    }

    void in()
    {
	Scanner sc = new Scanner(System.in);
	a = sc.nextLong();
	b = sc.nextLong();
	x = sc.nextLong();
    }

    void out(long n)
    {
	System.out.println(n);
    }
    
    void out(int n)
    {
	System.out.println(n);
    }

    void out(char c)
    {
	System.out.print(c);
    }
    
    void out(String s)
    {
	System.out.println(s);
    }
}


Measured memory_bytes: 22868
N = input()
a = map(int, raw_input().split())

if max(a)-min(a)>=2:
  print "No"
elif max(a)-min(a)==0:
  if N>=2*a[0] or N==a[0]+1:
    print "Yes"
  else:
    print "No"
else:
  cn = max(a)-a.count(min(a))
  if a.count(max(a))>=2 and cn>0 and N>=a.count(min(a))+2*cn:
    print "Yes"
  else:
    print "No"


Measured memory_bytes: 11328
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;


public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskT solver = new TaskT();
        solver.solve(1, in, out);
        out.close();
    }
    
    

    static class TaskT {
    	static int counter = 0;
        public void solve(int testNumber, InputReader in, PrintWriter out) {

        	int x = in.nextInt(); // total people
        	
        	
        	out.print(x ==0 ? 1 : 0);
        }
        
     
        
        

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        
        public long nextLong() {
            return Long.parseLong(next());
        }
    }
}


Measured memory_bytes: 32936
import math
N=int(input())
L=[]
tmp=[]
t=1
for i in range (N):
	t=t*(i+1)
	x,y=map(int,input().split())
	L.append([x,y])
for i in range(N-1):
	for j in range(i+1,N):
		z=math.sqrt((L[i][0]-L[j][0])**2+(L[i][1]-L[j][1])**2)
		tmp.append(z)
print((sum(tmp))*2/N)

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
	int h,w,i,j;
	while(1){
		scanf("%d%d",&h,&w);
		if(h==0 || w==0) return 0;
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

ll keta(ll a) {
	if (a == 0) return 0;
	return 1 + keta(a / 10);
}

void solve() {
	ll n;
	cin >> n;
	ll ans = 10000000001;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i != 0) continue;
		ll b = n / i;
		ans = min(ans, max(keta(i), keta(b)));
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 3652
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

int n;
string s;

int main(){
    cin >> n >> s;
    map<pair<string, string>, int> mp;
    REP(bit, (1 << n)){
        string a = "", b = "";
        REP(i, n){
            if(bit & (1 << i))a += s[i];
            else b += s[i];
        }
        mp[{a, b}]++;
    }
    LL ans = 0;
    REP(bit, (1 << n)){
        string a = "", b = "";
        REP(i, n){
            if(bit & (1 << i))a += s[i + n];
            else b += s[i + n];
        }
        reverse(ALL(a));
        reverse(ALL(b));
        ans += mp[{a, b}];
    }
    cout << ans << endl;
}

Measured memory_bytes: 87040
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
	static void Main(string[] args)
	{			
		//文字列を読み込む
		int[] line = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
		int H = line[0];
		int K = line[1];
		long[] Hn = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
		
		if(K >= H){
				Console.WriteLine(0);
		}else{
				Array.Sort(Hn);
				long answer = 0;
				for(int i=0; i<H-K; i++){
						answer += Hn[i];
				}
				Console.WriteLine(answer);
		}
	}
}

Measured memory_bytes: 37376
#include<bits/stdc++.h>
 
using namespace std;
using S = set<long long>;
using D = deque<long long>;
using L = vector<long long>;
using M = map<int,long long>;
using A = vector<vector<long long>>;
using Q = priority_queue<long long>;
using U = unordered_map<int,long long>; //mapとの違いはkeyの順番を保持していない

#define sorted(vector) sort(vector.begin(),vector.end()) //O(nlongn)
#define sortedreverce(vector) sort(vector.rbegin(),vector.rend()) //O(nlongn)
#define vmin(vector) *min_element(vector.begin(),vector.end()) //O(N)
#define vmax(vector) *max_element(vector.begin(),vector.end()) //O(N)
#define vsum(vector) accumulate(vector.begin(),vector.end(),0) //O(N)
#define vcount(vector,a) count(vector.begin(), vector.end(),a) //O(N)
#define bisect_left(vector,a) (lower_bound(vector.begin(),vector.end(),a)-vector.begin())
#define bisect_right(vector,a) (upper_bound(vector.begin(),vector.end(),a)-vector.begin())
#define vfind(vector,a) find(vector.begin(), vector.end(), a) != vector.end() //遅いからあんまり使うな
//存在確認はmap!!!!!!!!!!!!!か配列に埋め込んでcontinueで回避
//__gcd(a,b)はコンパイラがGCC時のみ

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s;
    
    cin>>s;
    cout<<min(vcount(s,'1'),vcount(s,'0'))*2<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
const int maxn = 310, p = 998244353;
char w[maxn];
int n, k, c1, res;
vector<int> c;
int dp[maxn][maxn][maxn], pf[maxn][maxn][maxn];
void add(auto &a, auto v) {
	a += v - p;
	a += (a>>31) & p;
}
void get_ans() {
	//for (int i = 0;i <= k;++i) dp[0][0][i] = 1;
	dp[0][0][0] = 1;
	int sum = 0;
	for (int i = 1;i <= c.size();++i) {
		int cp = c[i-1];
		sum += cp;
		for (int j = sum;j <= c1;++j) {
			for (int s = 0;s <= k;++s) {
				for (int w = 0;w <= j;++w) {
					int cost = max(0, w-cp);
					if (cost > s) break;
					add(dp[i][j][s], dp[i-1][j-w][s-cost]);
				}
			}
//			for (int w = 0;w <= j;++w) {
//				int cost = max(0, w - cp);
//				for (int s = cost;s <= k;++s) 
//					add(dp[i][j][s], dp[i-1][j-w][s-cost]);
//			}
//			for (int s = cost;s <= k;++s)
//				pf[i][j][s] = dp[i][j][s];

		}
	}
	for (int s = 0;s <= k;++s)
		add(res, dp[c.size()][c1][s]);
}
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> w+1 >> k;
	n = strlen(w+1);
	for (int i = 1, cnt = 0;i <= n+1;++i) {
		if (w[i] == '1') ++cnt;
		else c.pb(exchange(cnt, 0));
	}
	c1 = count(w+1, w+1+n, '1');
	k = min(k, c1);
	if (c.size() == 1) 
		return cout << 1 << '\n', 0;
	get_ans();
	cout << res << '\n';
}


Measured memory_bytes: 30876
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    int n;
    cin>>n;
    lvec a(n);
    rep(i,n)cin>>a[i];
    sort(all(a));
    lvec s(n+1,0);
    for(int i=0;i<n;i++)s[i+1]=s[i]+a[i];
    int ans;
    for(int i=0;i<n-1;i++){
        int m=i;
        ll cnt=s[i+1];
        bool ok=0;
        while(true){
            if(cnt*2<a[m+1])break;
            int k=ub(all(a),2*cnt)-a.begin();
            if(k==n){
                ok=1;
                break;
            }
            cnt+=s[k]-s[m+1];
            m=k-1;
        }
        if(ok){
            ans=n-i;
            break;
        }
        if(i==n-2){
            ans=1;
            break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1920
from sys import stdin
def main():
    n, c, k = map(int, stdin.readline().split())
    t = map(int, stdin.read().split())
    t.sort()
    p = t[0]
    ans = 0
    j = 0
    for i, x in enumerate(t):
        if x - p > k or i - j + 1 > c:
            ans += 1
            p = x
            j = i
    print ans + 1
main()


Measured memory_bytes: 11288
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<bits/stdc++.h>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()


int main() {
	int h,n;
	cin >> h >> n;
	vector<P> a(n);
	rep(i, n) {
		cin >> a[i].first >> a[i].second;
	}
	vector<int> d(h + 1, INT_MAX);
	d[0] = 0;
	rep(i, h) {
		if (d[i] == INT_MAX) {
			continue;
		}
		rep(j, n) {
			if (i + a[j].first <= h) {
				if (d[i + a[j].first] >= d[i] + a[j].second) {
					d[i + a[j].first] = d[i] + a[j].second;
				}
			}
			else {
				if (d[h] >= d[i] + a[j].second) {
					d[h] = d[i] + a[j].second;
				}
			}
		}
	}
	cout << d[h] << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int N, X;	cin >> N >> X;
	vector<int> m;
	int inputM;
	int answer = 0;
	for (int i = 0; i < N; ++i) {
		cin >> inputM;
		m.push_back(inputM);
	}
	sort(m.begin(), m.end());
	for (int i = 0; i < N; ++i) {
		if (X >= m[i]) {
			++answer;
			X -= m[i];
		}
	}
	answer += X / m[0];
	cout << answer << endl;
	cin >> N;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
holidays = ['','SAT', 'FRI','THU','WED','TUE','MON','SUN']
def print_ans(S):
    """Test Case
    >>> print_ans("SAT")
    1
    >>> print_ans("SUN")
    7
    """
    for i, day in enumerate(holidays):
        if S == day:
            print(i)

if __name__ == '__main__':
    S = input().rstrip()
    print_ans(S)




Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <stdlib.h>
#include <time.h> 
 
using namespace std;
long long mod=1e9+7;
long long INF=1e7;
double EPS = 1e-12;
typedef long long int lld;
double tick(){static clock_t oldt;clock_t newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt = newt;return diff;}
#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define repI(i,a,n) for(int i = (a); i <= (n); ++i)
#define repD(i,a,n) for(long long int i = (a); i >= (n); --i)
#define repDI(i,a,n) for(int i = (a); i >= (n); --i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define scd(a) scanf("%d",&a)
#define scd2(a,b) scanf("%d%d",&a,&b)
#define scd3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scf(a) scanf("%lf",&a)
#define scf2(a,b) scanf("%lf%lf",&a,&b)
#define scf3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define prL(a) printf("%lld\n",a)
#define prS(a) printf("%lld ",a)
#define prdL(a) printf("%d\n",a)
#define prdS(a) printf("%d ",a)
#define all(c) c.begin(), c.end()
#define sz(a) ((int)a.size())
#define Error(x) cout<< #x << " = " << (x) <<endl;
#define Error2(a,b) cout<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define Error3(a,b,c) cout<<"("<<#a<<" , "<<#b<<" , "<<#c<<" ) = ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<")\n";
#define Error4(a,b,c,d) cout<<"("<<#a<<" , "<<#b<<" , "<<#c<<" , "<<#d<<" ) = ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<" , "<<(d)<<")\n";
#define errop(a) cout<<#a<<" = ( "<<((a).x)<<" , "<<((a).y)<<" )\n";
#define mset(a, v) memset(a, v, sizeof(a))
#define popcount __builtin_popcountll
 
typedef pair<lld,lld> PA;
 
lld powP(lld a,lld b){
    if(b==0) return 1%mod;
    lld k;
    k=powP(a,b/2);
    k=k*k%mod;
    if(b%2==0) return k;
    else return a*k%mod;
}
 
bool bitSet(lld n,lld i){
    if((n&(1LL<<i))!=0) return true;
    else return false;
}
 
lld findGcd(lld a,lld b){
    if(a==0) return b;
    else return findGcd(b%a,a);
}
 
#define lim 300010
#define lim2 200010
#define qqqqqq 210
// Ab :)
// inline lld sqr(lld x) { return x * x; }
// unordered_map<lld,lld>::iterator it;
// std::ios::sync_with_stdio(false);
// priority_queue<PA> Q;
// lld dp[1<<18];

// vector<lld> G[lim];
// string S[lim];
lld A[lim],B[lim],C[lim];
// map<lld,lld> M;

int main(){
    lld T,i,p,j,l,n,e,r,b,c,k,m,q,a,d,w,x,y,u,v,z,t,curr,prev,sum,ans,pos,val,countA,indicator;
    t = 0;
    sc2(n,x);
    rep(i,1,n) {
        sc(k);
        t = findGcd(t, abs(x - k));
    }
    prL(t);
    return 0;
}

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

int main () {
int a, b;
	cin >> a >> b;
	if (a>=1 && a <= 12 && b>=1 && b<=31){
	} if (b > a or a == b){
		cout << a << endl;
	} else
		cout << a-1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ld;
int main()
{
    int n,i,j,W;
    cin>>n>>W;
    ld w[n],v[n];
    for(i=0;i<n;i++)
        cin>>w[i]>>v[i];
    ld dp[n+1][W+1];
    for(i=0;i<=W;i++)
        dp[0][i]=0;
    for(i=1;i<=n;i++)
    {
        for(j=0;j<=W;j++)
        {
            if(j>=w[i-1])
            {
                dp[i][j]=max(dp[i-1][j-w[i-1]]+v[i-1],dp[i-1][j]);
            }
            else
            {
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    cout<<dp[n][W];
    return 0;
}

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

typedef long long ll;
const ll MAXN =105;
const ll INF = 1e18;

ll n,sum, cap[MAXN][MAXN],p[MAXN];
vector<ll> adj[MAXN];
queue<pair<ll,ll>> q;

ll bfs(int s, int t){
    while(!q.empty())q.pop();
    
    p[0] = -2;
    q.push({0ll,INF});
    while(!q.empty()){
        ll cur = q.front().first;
        ll flow = q.front().second;
        q.pop();
        for (auto next : adj[cur]){
            if (p[next] == -1 && cap[cur][next] > 0){
                p[next] = cur;
                ll newflow = min(flow,cap[cur][next]);
                if(next == t)
                    return newflow;
                q.push({next,newflow});
            }
        }
    }
    return 0;
}

ll maxflow(int s, int t){
    ll ans = 0;
    
    while(1){
        memset(p,-1,sizeof(p));
        ll newflow = bfs(s,t);
		if(!newflow)break;
        ans += newflow;

		long long cur = t;
		while(cur != s){
			long long prev = p[cur];
			cap[prev][cur] -= newflow;
			cap[cur][prev] += newflow;
			cur = prev;
		}
	}
    return ans;
}

int main(){
    cin>>n;
    ll tmp;
	for(ll i =1;i<=n;i++){
        cin >> tmp;
		
		if(tmp>=0){
			adj[i].push_back(n+1);
			adj[n+1].push_back(i);
			cap[i][n+1]+=tmp;
			sum+=tmp;
		}
		if(tmp<0){
			adj[i].push_back(0);
			adj[0].push_back(i);
			cap[0][i]-=tmp;
		}
		for(int j = 2*i; j <= n;j += i){
			adj[i].push_back(j);
			adj[j].push_back(i);
			cap[i][j]= INF;
		}
	}

    cout << sum - maxflow(0,n+1) << "\n";
}

Measured memory_bytes: 3736