akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
const int INF = 0x0fffffff;

int N;
int M;

typedef pair<int, int> pii;
typedef pair<int, pii> piii;

map<pii, vector<piii>> G;
map<pii, int> V;

void slove() {
    priority_queue<piii> Q;
    Q.push(make_pair(-0, make_pair(0, -1)));

    while (!Q.empty()) {
        int c = - Q.top().first;
        pii p = Q.top().second;
        Q.pop();

        for (piii np : G[p]) {
            if (V[np.second] > V[p] + np.first) {
                V[np.second] = V[p] + np.first;
                Q.push(make_pair(-V[np.second], np.second));
                //cout << "(" << np.second.first+1 << "," << np.second.second << ") " << V[np.second] << endl;
            }
        }
    }

    if (V[make_pair(N-1,-1)] == INF) {
        printf("%d\n", -1);
    } else {
        printf("%d\n", V[make_pair(N-1,-1)] / 2);
    }
}
 
int main(int argc, char* argv[]) {
    //// for cin
    //ios::sync_with_stdio(false);
    //cin.tie(0);
 
    scanf("%d%d", &N, &M);

    G[make_pair(0, -1)].push_back(make_pair(0, make_pair(0,  0)));
    G[make_pair(0,  0)].push_back(make_pair(0, make_pair(0, -1)));

    G[make_pair(N-1, -1)].push_back(make_pair(0, make_pair(N-1,  0)));
    G[make_pair(N-1,  0)].push_back(make_pair(0, make_pair(N-1, -1)));

    for (int i = 0; i < N; ++i) {
        V[make_pair(i, 0)] = INF;
    }
    V[make_pair(0, -1)] = 0;
    V[make_pair(N-1, -1)] = INF;

    for (int i = 0; i < M; ++i) {
        int p;
        int q;
        int c;
 
        scanf("%d%d%d", &p, &q, &c);
 
        p--;
        q--;


        if (!V.count(make_pair(p, c))) {
            G[make_pair(p, c)].push_back(make_pair(1, make_pair(p, 0)));
            G[make_pair(p, 0)].push_back(make_pair(1, make_pair(p, c)));
            V[make_pair(p, c)] = INF;
        }
        if (!V.count(make_pair(q, c))) {
            G[make_pair(q, c)].push_back(make_pair(1, make_pair(q, 0)));
            G[make_pair(q, 0)].push_back(make_pair(1, make_pair(q, c)));
            V[make_pair(q, c)] = INF;
        }

        G[make_pair(p, c)].push_back(make_pair(0, make_pair(q, c)));
        G[make_pair(q, c)].push_back(make_pair(0, make_pair(p, c)));
    }
 
    slove();
 
    return 0;
}


Measured memory_bytes: 92152
import java.util.Scanner;
public class Main{ 
public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    if(a < b){
        if(b<c)System.out.println("Yes");
        else System.out.println("No");
      }  else System.out.println("No");
}
}


Measured memory_bytes: 26224
#include <cstdio>

int t, n, s, f, sum;

int main(){
    while(scanf("%d", &t) != EOF){
        if(t == 0) break;

        scanf("%d", &n);

        sum = 0;
        for(int i = 0; i < n; i++){
            scanf("%d %d", &s, &f);

            sum += (f - s);
        }

        if(sum < t) printf("%d\n", t - sum);
        else printf("OK\n");
    }


    return 0;
}

Measured memory_bytes: 2760
while True:
    H, W = [int(n) for n in input().split()]
    if H == 0 and W == 0:
        break
    for i in range(H):
        d, r = divmod(W, 2)
        if i%2 == 0:
            print('#.'*d+'#.'[0:r])
        else:
            print('.#'*d+'.#'[0:r])
    print()



Measured memory_bytes: 5620
#!/usr/bin/env python3
#ABC132 C
import sys
sys.setrecursionlimit(1000000)
from collections import deque

N = int(input())
d = list(map(int,input().split()))
d.sort()
if N % 2 == 0:
    print(d[N//2]-d[N//2-1])
else:
    print(0)


Measured memory_bytes: 14908
#include<bits/stdc++.h>
using namespace std;
const int maxn = 300 + 10;

int n, k, MOD;

inline int inc(int a, int b) { return (a + b >= MOD) ? (a + b - MOD) : (a + b); }
inline int dec(int a, int b) { return (a >= b) ? (a - b) : (a + MOD - b); }
inline int mul(int a, int b) { return 1LL * a * b % MOD; }

inline int power(int x, int k) {
	int tmp = 1;
	while(k) {
		if(k & 1) tmp = mul(tmp,x);
		x = mul(x,x);
		k >>= 1;
	}
	return tmp;
}

inline void updata(int &x, int y) { x = inc(x,y); }

int f[maxn][maxn], g[maxn][maxn];
int main() {
//	freopen("data.in","r",stdin);
  scanf("%d%d%d", &n, &k, &MOD);
  g[0][0] = 1;
	for(int i = 0;i <= n;i ++) {
		for(int j = 0;j <= n;j ++) {
      if(i == 0 && j == 0) continue;
			if(i != 0) updata(g[i][j],g[i - 1][j]);
			if(j != 0) updata(g[i][j],mul(i + 1,g[i][j - 1]));
		}
	}
	f[0][0] = 1;
	for(int i = 1;i <= k;i ++) {
		for(int j = 0;j <= n;j ++) {
      for(int l = 0;l <= j;l ++) updata(f[i][j],mul(f[i - 1][j - l],g[j - l][l]));
		}
	}
	int Ans = f[k][n];
	printf("%d\n", Ans);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int MAX = 8005;
const int MID = 8000;
char S[MAX];
int N, X, Y, cc;
bitset<MAX * 2 + 1> xbit, ybit;

int main(){
    scanf("%s", S);
    N = strlen(S);
    scanf("%d %d", &X, &Y);
    int i = 0;
    for(; S[i] == 'F'; i++);
    xbit.set(MID), ybit.set(MID);
    xbit <<= i;
    int st = 1;
    for(; i < N; i++){
        if(S[i] == 'F')     cc++;
        else{
            if(st)  xbit = (xbit << cc) | (xbit >> cc);
            else    ybit = (ybit << cc) | (ybit >> cc);
            st ^= 1;
            cc = 0;
        }
    }
    if(cc){
        if(st)  xbit = (xbit << cc) | (xbit >> cc);
        else    ybit = (ybit << cc) | (ybit >> cc);
    }
    if(xbit[MID + X] && ybit[MID + Y])  puts("Yes");
    else puts("No");
    return 0;
}


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

#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll MAX = 100000005;

void solve(long long N){
    vector<ll> res(MAX);
    rep(i,N+1){
        if(i == 0) continue;
        for(ll j = i; j <= N+1; j += i){
            res[j]++;
        }
    }
    ll ans = 0;
    rep(i,N+1){
        ans += i * res[i];
    }
    cout << ans << endl;

}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 784400
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e16;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){     
        IsPrime.resize(max+1,true); 
    } 
    IsPrime[0] = false;
    IsPrime[1] = false;

    for(size_t i=2; i*i<=max; ++i) 
        if(IsPrime[i])
            for(size_t j=2; i*j<=max; ++j) 
                IsPrime[i*j] = false;      
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    sieve(55555);
    int n;
    cin >> n;
    vector<int> ans;
    rep(i,1,55555){
        if (IsPrime[i] && i%5 == 1)  ans.push_back(i);
    }
    rep(i,n-1) cout << ans[i] << " ";
    PRINT(ans[n-1]);
}


Measured memory_bytes: 888
#include <iostream>
using namespace std;
 
int gcd(int a, int b)
{	
   if(a>=b){
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
   }else{if (b%a == 0)
   {
       return(a);
   }
   else
   {
       return(gcd(a, b%a));
   }}
}
int main(){
  short int K=0;
  int result=0;
  cin >> K;
  for(int a=1;a<=K;a++){
   for(int b=1;b<=K;b++){
   	for(int c=1;c<=K;c++){
	
    result+=gcd(a,gcd(b,c));
    }
   } 
  } 
  cout << result;
  
  
 return 0; 
}

Measured memory_bytes: 3624
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int main() {
    int k;
    cin >> k;
    int x[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << x[k-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

void trace(int A[], int N) {
    int i;
    for(i = 0; i < N; i++) {
        if(i > 0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}

void insertionSort(int A[], int N) {
    int i;
    for(i = 1; i < N; i++) {
        int t = A[i];
        int j = i - 1;
        while(j >= 0 && t < A[j]) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = t;
        trace(A, N);
    }
}

int main() {
    int A[100], N, i, j;
    scanf("%d", &N);
    for(i = 0; i < N; i++) scanf("%d", &A[i]);

    trace(A, N);
    insertionSort(A, N);

    return 0;
}


Measured memory_bytes: 2036
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <unordered_map>

using namespace std;

const int maxN = 2e5 + 10;

#define FORU(i, l, r) for (int i = l; i <= r; ++i)
#define FORD(i, r, l) for (int i = r; i >= l; --i)
#define REPU(i, r) for (int i = 0; i < r; ++i)
#define LL long long
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define PINT pair < int, int >
#define BIT(x, i) ((x >> i) & 1)
#define NUM_SET_BIT __builtin_popcountll

int f[maxN], pos[26], nxt[maxN][26];
string s;

int dp(int i) {
    if (i >= s.length()) return 0;
    if (f[i] != -1) return f[i];
    f[i] = s.length() + 1;
    REPU(j, 26) {
        f[i] = min(f[i], 1 + dp(nxt[i][j]));
    }
    return f[i];
}

void trace(int i) {
    if (i >= s.length()) return;
    REPU(j, 26)
        if (f[i] == dp(nxt[i][j]) + 1) {
            printf("%c", char(j + 'a'));
            trace(nxt[i][j]);
            return;
        }
}

int main() {
    cin >> s; s = "a" + s;
    REPU(i, 26) pos[i] = s.length();
    FORD(i, s.length() - 1, 0) {
        REPU(j, 26) nxt[i][j] = pos[j];
        pos[s[i] - 'a'] = i;
    }
    memset(f, 255, sizeof(f));
    dp(0); trace(0);
}


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

int n;
pair<long long, long long> sol = make_pair(1, 1);
pair<int, int> r;

int main() {

    scanf("%d", &n);
    for(int i = 1; i <= n; ++i) {
        scanf("%d %d", &r.first, &r.second);
        long long kf = sol.first / r.first + (sol.first % r.first > 0);
        long long ks = sol.second / r.second + (sol.second % r.second > 0);
        long long k = max(kf, ks);

        sol = make_pair(k * r.first, k * r.second);
    }

    printf("%lld\n", sol.first + sol.second);

    return 0;
}

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

#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define rALL(x) x.rbegin(),x.rend()

using namespace std;
using ll=long long;



int main(){
  int n;cin>>n;
  vector<ll> a(n);
  int sum=0;
  rep(i,n){
    cin>>a[i];
    sum^=a[i];
  }
  for(auto x:a)cout<<(sum^x)<<' ';
}

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int64_t n, m;
    cin >> n >> m;
    static int64_t a[100000], sum[100001];
    for(int i=0;i<n;++i) cin >> a[i];
    sort(a, a+n, greater<int64_t>());
    sum[0] = 0;
    for(int i=0;i<n;++i) sum[i+1] = sum[i] + a[i];

    int64_t left = 0, right = 200001;
    while(right - left > 1){
        int64_t mid = (left + right) / 2;
        int i = n;
        int64_t cnt = 0;
        for(int j=0;j<n;++j){
            for(;i>0;--i){ if(a[i-1] + a[j] >= mid) break; }
            cnt += i;
        }
        if(cnt < m) right = mid;
        else left = mid;
    }

    int i = n;
    int64_t cnt = 0, ans = 0;
    for(int j=0;j<n;++j){
        for(;i>0;--i){ if(a[i-1] + a[j] >= right) break; }
        cnt += i;
        ans += a[j] * i + sum[i];
    }
    cerr << right << " " << cnt << " " << ans << endl;
    ans += (m - cnt) * left;
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <stack>

#define INFINITY 2000000000

using namespace std;

int main(){

	int V,E,from,to,dist;

	scanf("%d %d",&V,&E);
	long long int table[V][V];

	for(int i = 0; i < V; i++){
		for(int k = 0; k < V; k++){
			if(i != k){
				table[i][k] = INFINITY;
			}else{
				table[i][k] = 0;
			}
		}
	}

	for(int i = 0; i < E; i++){
		scanf("%d %d %d",&from,&to,&dist);
		table[from][to] = dist;
	}

	for(int k = 0; k < V; k++){
		for(int i = 0; i < V; i++){
			if(table[i][k] == INFINITY)continue;
			for(int j = 0; j < V; j++){
				if(table[k][j] == INFINITY)continue;
				table[i][j] = min(table[i][j],table[i][k]+table[k][j]);
			}
		}
	}

	bool FLG = true;

	for(int i = 0; i < V; i++){
		if(table[i][i] < 0){
			FLG = false;
			break;
		}
	}

	if(!FLG)printf("NEGATIVE CYCLE\n");
	else{
		for(int i = 0; i < V; i++){
			if(table[i][0] == INFINITY)printf("INF");
			else{
				printf("%lld",table[i][0]);
			}

			for(int k = 1;k < V; k++){
				if(table[i][k] == INFINITY)printf(" INF");
				else{
					printf(" %lld",table[i][k]);
				}
			}
			printf("\n");
		}
	}

    return 0;
}




Measured memory_bytes: 2816
#include<bits/stdc++.h> 
    using namespace std; 
    #define ll long long int
    #define fi first
    #define se second
    #define pb push_back
    #define mod 1000000007
    #define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll power(ll x, ll y, ll p)  
    {  
        ll res = 1;x = x % p;if (x == 0)return 0;while (y > 0)  
        {if (y & 1) res = (res*x) % p;  y = y>>1; x = (x*x) % p;  }  return res;  
    }
    bool sortinrev(const pair<vector<int>,int>&a,const pair<vector<int>,int>&b){if(a.fi==b.fi)return b.se>a.se;return a.fi>b.fi;}
    void run(vector<int>v){for(int i=0;i<v.size();i++)cout<<v[i]<<" ";cout<<endl;}
    void solve()
    {
        int n;
        cin>>n;
        ll a[n];ll sum=0;
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
            sum+=a[i];
        }
        // cout<<sum<<endl;
        ll table[n][n];
        for(int gap=0;gap<n;gap++)
        {
            for(int i=0,j=gap;j<n;++i,++j)
            {
                ll x = ((i+2)<=j)?table[i+2][j]:0;
                ll y = ((i+1)<=(j-1))?table[i+1][j-1]:0;
                ll z = ((i)<=(j-2))?table[i][j-2]:0;
                table[i][j] = max(a[i]+min(x,y),a[j]+min(y,z));
            }
        }
        cout<<2*table[0][n-1]-sum<<endl;


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

Measured memory_bytes: 70144
// Author: Gaurang_Kothiya

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>
 
using namespace std;
using namespace __gnu_pbds;  

#define data_set(type) tree<type,null_type,less<type>,rb_tree_tag,tree_order_statistics_node_update>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define ld long double
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(int i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()
#define ook(num) order_of_key(num)
#define fbo(num) find_by_order(num)
#define gcd(a,b) __gcd(a,b)
#define bits(n) __builtin_popcountll(n)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846

const int inf= 1e9 +1;
const int inf64= 1e18 -1;
const int MOD= 1e9 +7;



void Solve()
{
	int x,k,d;
	cin>>x>>k>>d;
	x=abs(x);
	int dist=x/d ;
	if(dist>=k)
	{
		x= x-k*d;
		cout<<x;
	}
	else
	{
		x = x- (dist)*d;
		int remain= k-dist;
		int rop= abs(x-d);
		if(remain%2) cout<<rop;
		else cout<<x;
	}
}
 
signed main() 
{
	speed		

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);	

	int q=1;
	//cin>>q;
	
	while(q--)
	Solve();
		
	return 0;
} 

Measured memory_bytes: 3636
N, L = (int(a) for a in input().split())
if N + L -1 < 0:
    x = N + L -1
elif L < 0 and N + L -1 >= 0:
    x = 0
else:
    x = L
sum = 0
for i in range(1,N+1):
    if x == L + i - 1:
        continue
    sum += L + i - 1
print(sum)

Measured memory_bytes: 38384
N = int(input())
L_0 = 2
L_1 = 1
cur = 0
for i in range(N):
    if i==0:
        cur = L_0
    elif i==1:
        prev = L_1
        cur += L_1 
    else:
        tmp = cur
        cur += prev
        prev = tmp
        
print(cur) if N!=1 else print(1)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Numerics;

    class Program
    {
        static void Main(string[] args)
        {
            var N = BigInteger.Parse(Console.ReadLine());
            var Ts = new List<BigInteger>();
            for(var i = 0; i < N; i++)
            {
                Ts.Add(BigInteger.Parse(Console.ReadLine()));
            }
            if(N==1)
            {
                Console.WriteLine(Ts[0]);
                return;
            }

            Func<BigInteger, BigInteger, BigInteger> Euclidean = (a, b) =>
            {
                var mul = a * b;
                if (a < b)
                {
                    var tmp = a;
                    a = b;
                    b = tmp;
                }
                var r = a % b;
                while (r != 0)
                {
                    a = b;
                    b = r;
                    r = a % b;
                }
                return mul / b;
            };

            var answer = Euclidean(Ts[0],Ts[1]);
            for (int i=2;i<N;i++)
            {
                answer = Euclidean(answer, Ts[i]);
            }
            Console.WriteLine(answer);
        }
    }


Measured memory_bytes: 13524
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 17;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1E-11;

ll in[100050];
int main() {
	int N, A, B, i;
	scanf("%d %d %d", &N, &A, &B);
	for (i = 1; i <= N; i++) scanf("%lld", &in[i]);
	
	ll st = 1, en = INF, mi, rv = en + 1;
	while (st <= en) {
		mi = (st + en) / 2;
		
		ll c = 0;
		for (i = 1; i <= N; i++) {
			ll t = in[i] - B*mi;
			if (t < 0) continue;
			c += (t + (A - B) - 1) / (A - B);
		}
		if (c <= mi) {
			rv = mi;
			en = mi - 1;
		}
		else st = mi + 1;
	}
	return !printf("%lld\n", rv);
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, A, B, C, D, E int
	fmt.Scan(&N, &A, &B, &C, &D, &E)
	p := []int{A, B, C, D, E}
	sort.Ints(p)
	x := p[0]
	fmt.Println((N-1)/x + 5)
}


Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

ll C[3000][3000];
void com(){
    C[0][0]=1;
    for(ll i=1;i<2010;i++){
        for(ll j=0;j<i+1;j++){
            if(j==0||j==i) C[i][j]=1;
            else{
                C[i][j]=C[i-1][j-1]+C[i-1][j];
                C[i][j]%=1000000007;
            }
        }
    }
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    com();
    rep2(i,1,k+1){
        ll ans=0;
        if(i==1){
            ans=n-k+1;
            cout<<ans<<endl;
            continue;
        }
        rep2(j,i-1,n-k+1){
            ll ans1=C[k-1][i-1]*C[j-1][i-2];ans1%=MOD;
            ans+=ans1*(n-k-j+1);ans%=MOD;
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 47744
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    ll N, M; cin >> N >> M;
    vector<ll> A(N);
    for(int i=0; i<N; i++) cin >> A[i];

    sort(A.begin(), A.end());
    vector<ll> S(N+1);
    for(int i=0; i<N; i++) S[i+1] = S[i] + A[i];

    // 回数が M を超えない最大
    ll ub = INF, lb = 0;
    while(ub - lb > 1) {
        // mid 以上はいくつか (上ほどすくない)
        ll mid = (ub + lb) / 2;
        ll sum = 0;
        for(int i=0; i<N; i++) {
            ll target = mid - A[i];
            sum += N - (lower_bound(A.begin(), A.end(), target) - A.begin());
        }

        // fprintf(stderr, "mid = %lld, sum = %lld\n", mid, sum);
        if(sum < M) ub = mid;
        else lb = mid;
    }

    // fprintf(stderr, "ub = %lld\n", ub);
    
    // ub 以上のものは M 個以下しかない
    ll ans = 0;
    vector<int> ptr(N);
    for(int i=0; i<N; i++) {
        // p 以上のところはとっていい
        ll target = ub - A[i];
        int p = lower_bound(A.begin(), A.end(), target) - A.begin();
        ans += (S[N] - S[p]) + (N - p) * A[i];
        M -= N - p;
        ptr[i] = p;
    }

    ans += M * lb;
    /*
    // 回数が M を超える最小 -> lb
    for(int i=0; i<N; i++) {
        ll target = lb - A[i];
        int q = lower_bound(A.begin(), A.end(), target) - A.begin();
        if(ptr[i] - q > M) {
            ans += lb * M;
            M = 0;
            break;
        }
        else {
            ans += (S[ ptr[i] ] - S[q]) + (ptr[i] - q) * A[i];
            M -= ptr[i] - q;
            ptr[i] = q - 1;
        }
    }

    fprintf(stderr, "M = %lld\n", M);
    
    // 値、インデックス
    priority_queue< pair<ll, ll> > que;
    for(int i=0; i<N; i++) {
        if(ptr[i] < 0) continue;
        que.emplace(A[i] + A[ ptr[i] ], i);
    }

    while(M > 0) {
        assert(que.size());
        ll val, idx; tie(val, idx) = que.top(); que.pop();
        fprintf(stderr, "val = %lld\n", val);
        ans += val; M--;
        if(--ptr[idx] >= 0) que.emplace(A[idx] + A[ ptr[idx] ], idx);
    }
    */

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


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

int main() {
  int n,m; cin>>n >>m;
  vector<pair<pii, int> > v(m);
  rep(i,m){
    cin>>v[i].first.first >>v[i].first.second; 
    v[i].second =i;
  }
  sort(v.begin(), v.end());
  vector<pii>  vec(m);
  rep(i,m){
    int j= v[i].second;
    vec[j].first= v[i].first.first;
    if(i==0 ){vec[j].second= 1;}
    else if(v[i].first.first!= v[i-1].first.first ){
      vec[j].second=1;
    }
    else{vec[j].second= vec[v[i-1].second ].second+1;}
  }

  rep(i,m){
    int n1=vec[i].first;
    int n2= vec[i].second;
    printf("%06d",n1);   
    printf("%06d",n2);
    cout<<endl;
  }
}



Measured memory_bytes: 5456
n = int(input())
a = list(map(int, input().split()))
b = []
if len(a)%2==0:
  for i in range(len(a)-1, 0, -2):
    b.append(a[i])
  for i in range(0, len(a), 2):
    b.append(a[i])
else:
  for i in range(len(a)-1, -1, -2):
    b.append(a[i])
  for i in range(1, len(a), 2):
    b.append(a[i])
print(" ".join(map(str, b)))

Measured memory_bytes: 29764
#include<iostream>
#include<vector>
#include<string>

int main(){
    char c;
    std::cin >> c;
    if(c >= 'a' && c <= 'z'){
        std::cout << "a" << std::endl;
    }else{
        std::cout << "A" << std::endl;
    }
    return 0;
}


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

int main()
{
    int n, d, a[13];

    while( cin >> n )
    {
        if( n == 0 )
            break;

        for( int i = 0; i < 13; i++ )
            a[i] = 0;

        for( int i = 0; i < n; i++ )
        {
            cin >> d;
            a[d/10]++;
        }

        for( int i = 0; i < 6; i++ )
            cout << a[i] << endl;

        int sum = 0;
        for( int i = 6; i < 13; i++ )
            sum += a[i];
            
        cout << sum << endl;
    }
    return 0;
}



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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-10;
bool com(const string &a, const string &b) {
	if (a.size() != b.size()) return a.size() < b.size();
	else {
		for (int i = 0; i < a.size(); i++) {
			if (a[i] != b[i])return a[i] < b[i];
		}
	}
}
signed main() {
	int n; cin >> n; vector<string>v;
	map<string, int>m;
	rep(i, 0, n) {
		string s; int a; cin >> s >> a;
		m[s] += a;
		if (find(all(v), s) == v.end())v.push_back(s);
	}
	sort(all(v), com);
	rep(i, 0, v.size()) {
		cout << v[i] << " " << m[v[i]] << endl;
	}

	return 0;
}

Measured memory_bytes: 3184
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n,a,b,c,d,e;
    cin>>n>>a>>b>>c>>d>>e;
    ll m=min({a,b,c,d,e});
    cout<<(n+m-1)/m+4<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include <cassert>
#include <algorithm>
#include <functional>
using namespace std;


int main() {
	int X, A;
	cin >> X >> A;
	if (X < A) {
		cout << 0;
	}
	else if(X >= A) {
		cout << 10;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX
#define MOD 1000000007
#define MEM_SIZE = 1e5+5;

template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}

//-----CODE------//

void solve(void)
{
  int N;
  cin>>N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++)
  {
    cin>>vec[i];
  }
  int ANS = 0;
  int MIN = INF;
  for (int i = 0; i < N; i++)
  {
    if(MIN >= vec[i])
    {
      ANS++;
      MIN = vec[i];
    }
  }
  cout<<ANS<<endl;
  
  

  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(8);
  solve();

 
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


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

	long long dp[101][100001];

	for (int i = 0; i <= n; i++) {
		dp[i][0] = 0;
	}
	for (int j = 0; j <= w; j++) {
		dp[0][j] = 0;
	}

	for (int i = 1; i <= n; i++) {
		
		int wi;
		long long vi;
		cin >> wi >> vi;

		for (int j = 1; j <= w; j++) {
			if (j < wi) {
				dp[i][j] = dp[i - 1][j];
				continue;
			}
			dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - wi] + vi);
		}
	}

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

Measured memory_bytes: 79104
import java.util.*;
public class Main
{
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
    int k=sc.nextInt();
    int a=sc.nextInt();
    int b=sc.nextInt();
    int c=a%k;
    int d=a+(k-c);
    if(c==0)
    {
      System.out.println("OK");
    }
    else if(b%k==0)
    {
       System.out.println("OK");
    }
    else if(c!=0)
    {
      if(d<=b)
      {
        System.out.println("OK");
      }
      else
      {
         System.out.println("NG");
      }
    }
    else
    {
       System.out.println("NG");
    }
  }
}
    

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

int main()
{
    char x, y;
    cin >> x >> y;
    if(x > y){
        cout << '>' << endl;
    }
    else if(x < y){
        cout << '<' << endl;
    }
    else{
        cout << '=' << endl;
    }
    return 0;
}

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

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

int main(){
    int n;
    cin >> n;
    map<P,int> freq;
    for(int i = 1;i<=n;++i){
        P p = f(i);
        freq[p]++;
    }
    ll ans = 0;
    for(int i = 1; i <= n;++i){
        P p = f(i);
        P q(p.second,p.first);
        ans += freq[q];
    }
    cout << ans << endl;
}

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

struct Point{
    int x,y;
};

void swap(Point* a,Point* b);

bool check(int j,int* used,int count);

int main(){
    int N;
    Point red[100],blue[100];
    cin >> N;
    for(int i=0; i<N; i++)
    cin >> red[i].x >> red[i].y;
    for(int i=0; i<N; i++)
    cin >> blue[i].x >> blue[i].y;

    //ソート 赤はyが大きい順,青はxが小さい順 ここ重要
    for(int i=0; i<N-1; i++){
        for(int j=i; j<N; j++){
            if(red[i].y < red[j].y)
            swap(&red[i],&red[j]);
            if(blue[i].x > blue[j].x)
            swap(&blue[i],&blue[j]);
        }
    }

    //ペアになった数を数える
    int ans=0;
    int used[100],count=0;//既に使われた赤い点をスキップ
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            bool a=check(j,used,count);
            if(a==false)
            continue;
            if(blue[i].x>red[j].x && blue[i].y>red[j].y){
                ans++;
                used[count]=j;
                count++;
                break;
            }
        }
    }

    cout << ans << "\n";

    return 0;
}

//ソート用の交換関数
void swap(Point* a,Point* b){
    Point tmp;
    tmp=*a;
    *a=*b;
    *b=tmp;
    return;
}

//使われた赤い点リストにその数があればスキップ(カウンタ+=bool)
bool check(int j,int* used,int count){
    for(int i=0; i<count; i++){
        if(*(used+i)==j)
        return false;
    }
    return true;
}

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

multiset<lint> lis;
struct Graph {
    struct Edge { int from; int to; lint cost; };
    struct Node {
        Node() : par(-1), done(false), dist(INF) {}
        int index;
        int par;
        bool done;
        lint dist;
        lint a;
        lint ans;
        vector<Edge> edge;
    };

    int n;
    vector<Node> nodes;
    vector<Edge> edges;
    const static lint INF = 1e18;

    Graph(int n) : n(n) {
        nodes.resize(n);
        for(int i=0; i<n; i++)  nodes[i].index = i;
    }

    void add_edge(int from, int to, lint cost) {
        nodes[from].edge.push_back(Edge{from, to, cost});
        edges.push_back(Edge{from, to, cost});
    }

    void dfs(int idx, int par) {
        auto it = lis.lower_bound(nodes[idx].a);
        lint num = (it != lis.end() ? *it : 1e18);

        if(it == lis.end()) {
            lis.insert(nodes[idx].a);
            nodes[idx].ans = lis.size();
        } else {
            lis.erase(num);
            lis.insert(nodes[idx].a);
            nodes[idx].ans = lis.size();
        }

        for(auto [from, to, cost] : nodes[idx].edge) {
            if(to == par) continue;
            dfs(to, idx);
        }

        lis.erase(nodes[idx].a);
        if(num != 1e18) lis.insert(num);
    }
};

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

    Graph g(n);
    for(int i=0; i<n; i++) cin >> g.nodes[i].a;
    for(int i=0; i<n-1; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        g.add_edge(u, v, 1);
        g.add_edge(v, u, 1);
    }

    g.dfs(0, -1);
    for(int i=0; i<n; i++) {
        cout << g.nodes[i].ans << endl;
    }
}

Measured memory_bytes: 45568
from fractions import gcd
N, = map(int, input().split())
X = list(map(int, input().split()))
rs = [0] * N
for i in range(N-1, 0, -1):
    rs[i-1] = gcd(rs[i], X[i])
ls = [0] * N
for i in range(N-1):
    ls[i+1] = gcd(ls[i], X[i])

s = 0
for i in range(N):
    s = max(s, gcd(ls[i], rs[i]))
print(s)


Measured memory_bytes: 89580
#include <iostream>

int main()
{
    int const FIRST = 100000;
    int n, debt = FIRST;

    std::cin >> n;

    for(int i = 0; i < n; i++) {
        debt /= 20;
        debt *= 21;
        if(debt % 1000 != 0)
            debt = debt / 1000 * 1000 + 1000;
    }

    std::cout << debt << std::endl;

    return 0;
}

Measured memory_bytes: 1160
N=int(input())
A=[0]+list(map(int,input().split()))
B=[0 for i in range(N+1)]
ans=[]
for i in range(1,N+1)[::-1]:
    #print(i)
    cnt=0
    for j in range(1,N+1):
        #print(i,j)
        if j*i>N:
            break
        if B[j*i]==1:
            cnt+=1
    if A[i]%2!=cnt%2:
        B[i]=1
        ans.append(i)
print(len(ans))
ans.sort()
print(*ans)
#print(A)

Measured memory_bytes: 14028
#include <iostream>

#define swap(a, b) a^=b^=a^=b

using namespace std;

int main() {

    int N, A[100], count = 0;
    cin >> N;

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

    for (int i = 0; i < N - 1; i++) {
        int min = i;
        for (int j = i + 1; j < N; j++) {
            if (A[min] > A[j]) {
                min = j;
            }
        }
        if (min != i) {
            swap(A[i], A[min]);
            count++;
        }
    }

    for (int i = 0; i < N; i++) {
        cout << A[i];
        if (i < N - 1) {
            cout << " ";
        } else {
            cout << endl;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3080
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << 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; }

void solve() {
	int d; cin >> d;
    vector<int> c(d);
    rep(i, d) cin >> c[i];
    vector<vector<int>> s(d, vector<int>(26));
    vector<int> ids(26);
    rep(i, d) {
        rep(j, 26) {
            cin >> s[i][j];
        }
        iota(all(ids), 0);
        sort(all(ids), [&](int x, int y){ return s[i][x] > s[i][y]; });
        cout << ids[0] + 1 << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

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

shojikin = 1000
kabu = 0
#l[商、あまり]
l = [0,0]
s = [0,0]
for i in range(n-1) :
    if kabu == 0 : #所持株が０なら買う
        if a[i] < a[i+1] :
            l[0] = shojikin // a[i]
            l[1] = shojikin % a[i]
            shojikin = l[1]
            kabu += l[0]
            l[0] = 0
            l[1] = 0
    if kabu > 0 :
        if a[i] > a[i+1] :
            shojikin += kabu * a[i]
            kabu = 0

if kabu > 0 :
    shojikin += kabu * a[n-1]

print(shojikin)


Measured memory_bytes: 9152
loop do
  n = gets.to_i
  break if n == 0
  data = n.times.map{gets.split.map(&:to_i)}

  weight = 0
  check = data.sort_by{|a,b| b}.all? do |a,b|
    weight += a
    weight <= b
  end
  puts "Yes" if check
  puts "No" if not check
end

Measured memory_bytes: 6116
open System
let R T = stdin.ReadLine()|> T
let RS T = stdin.ReadLine().Split()|>Array.map T
let Mod = (1e9|>int64)+7L
[<EntryPoint>]
let main argv =
    let N = R int
    let P = RS int
    let mutable m = 300000
    let mutable ans = 0
    for i in [0..N-1] do
        if P.[i]<=m then
            ans <- ans + 1
            m <- P.[i]
    stdout.WriteLine ans
    0


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

int main(){
  string s;
  cin >> s;
  int count=0;
  r(i,s.length()-1){
    if(s.at(i)!=s.at(i+1))count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#include <sstream>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007
#define M 998244353

using namespace std;

int main(){
    lli k,n,a,Max=0;
    vector<lli> vec,def;
    lli i,j;
    cin>>k>>n;
    rep(i,0,n){
        cin>>a;
        vec.push_back(a);
    }
    rep(i,1,n){
        Max=max(Max,vec[i]-vec[i-1]);
    }
    Max=max(Max,k-vec[n-1]+vec[0]);
    cout<<k-Max<<endl;
}


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

int main () {
  int H, W;
  cin >> H >> W;
  vector<string> phase(H);
  for (int i = 0; i < H; i++) {
    cin >> phase.at(i);
  }
  //ここまでで一応元のデータは入れ終えた
  vector<bool> vertical(H, true), horizontal(W, true);
  for (int j = 0; j < W; j++) {
    for (int i = 0; i < H; i++) {
      if(phase.at(i).at(j) != '.') {
        horizontal.at(j) = false;
        break;
      }
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if(phase.at(i).at(j) != '.') {
        vertical.at(i) = false;
        break;
      }
    }
  }
  for (int j = 0; j < H; j++) {
    for (int i = 0; i < W; i++) {
      if(vertical.at(j) == false && horizontal.at(i) == false) {
        cout << phase.at(j).at(i);
      }
    }
    cout << endl;
  }
}
  


Measured memory_bytes: 3612
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	int n, k;
	string s;
	cin >> n >> k >> s;
	vector<int> v;
	int cnt = 1;
	for(int i = 1; i < s.length(); i++){
		if(s[i] == s[i - 1]){
			cnt++;
		} else {
			v.push_back(cnt);
			cnt = 1;
		}
	}
	v.push_back(cnt);
	if(v.size() <= 2){
		cout << n - 1 << endl;
		return 0;
	}
	long long int ans = 0;
	cnt = 0;
	vector<bool> ischecked(100001, false);
	for(int i = 1; i < min(k + 1, (int)v.size() - 1); i++){
		ans += v[i];
		ischecked[i] = true;
		cnt++;
	}
	for(int i = 1; i < min(k + 1, (int)v.size() - 1); i++){
		if(ischecked[v.size() - 1 - i]) continue;
		ans += v[v.size() - 1 - i];
		ischecked[v.size() - 1 - i] = true;
		cnt++;
	}
	for(int i = 0; i < v.size(); i++){
		if(!ischecked[i]) ans += v[i] - 1;
	}
	if(cnt < 2 * k) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 1020
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
const double PI = acos(-1);
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

int n;
ll ans;
int a[N * 10];
char s[N * 10];

int main() {
    scanf("%s", s + 1);
    n = strlen(s + 1);
    for (int i = 1; i <= n; i++) {
        a[i] = s[i] - '0';
    }
    a[0] = 0;
    for (int i = n; i >= 1; i--) {
        if (a[i] < 5) {
            ans += a[i];
        } else if (a[i] > 5) {
            ans += 10 - a[i];
            a[i - 1]++;
        } else {
            ans += 5;
            a[i - 1] += (a[i - 1] >= 5);
        }
    }
    if (a[0]) ans++;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define pb(x) push_back(x) 
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define mod 1000000007
#define f first
#define s second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops\
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
int main()
{
	sync;
	ll a,b,c,d,lcm;
	cin>>a>>b>>c>>d;
	lcm=(c*d)/__gcd(c,d);
	ll ans=b/c-a/c+(a%c==0)+b/d-a/d+(a%d==0)-(b/lcm-a/lcm+(a%lcm==0));
	cout<<(b-a+1)-ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool isnode[705][705]={false};
bool used[705]={false};
ll val_k[705]={0},val_g[705]={0};
bool dp[705][705]={false};
ll col[705]={0};
ll n,m;
void dfs(ll pos,ll col_n){
  col[pos]=col_n;
  if(col_n%2==1) col_n++;
  else col_n--;
  for(int i=1;i<=n;i++){
    if(!used[i]&&isnode[pos][i]){
      used[i]=true;
      dfs(i,col_n);
    }
  }
}
int main(){
  cin>>n>>m;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      if(i==j) isnode[i][j]=false;
      else isnode[i][j]=true;
    }
    used[i]=false;
  }
  for(int i=0;i<m;i++){
    ll a,b;
    cin>>a>>b;
    isnode[a][b]=false;
    isnode[b][a]=false;
  }
  ll nc=1;
  for(int i=1;i<=n;i++){
    if(!used[i]){
      used[i]=true;
      dfs(i,nc);
      nc+=2;
    }
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      if(isnode[i][j]){
        if(col[i]==col[j]){
          cout<<-1<<endl;
          return 0;
        }
      }
    }
  }
  for(int i=1;i<=n;i++) {
    if(col[i]%2==1) val_k[(col[i]+1)/2]++;
    else val_g[col[i]/2]++;
  }
  for(int i=0;i<705;i++){
    for(int j=0;j<705;j++) dp[i][j]=false;
  }
  ll max_t=0;
  for(int i=1;i<=n;i++){
    if(val_k[i]>0||val_g[i]>0) max_t=i;
  }
  dp[0][0]=true;
  for(int i=0;i<max_t;i++){
    ll delta=abs(val_k[i+1]-val_g[i+1]);
    for(int j=0;j<705;j++){
      if(dp[i][j]){
        if(j-delta>=0){
          dp[i+1][j-delta]=true;
        }
        else dp[i+1][delta-j]=true;
        dp[i+1][j+delta]=true;
      }
    }
  }

  ll max_d=17441744;
  for(int i=0;i<705;i++){
    if(dp[max_t][i]){
      max_d=i;
      break;
    }
  }
  ll a=(n+max_d)/2,b=(n-max_d)/2;
  cout<<(a*(a-1)/2)+(b*(b-1)/2)<<endl;
}


Measured memory_bytes: 1280
n,m=list(map(int,input().split()))
r=[[]for i in range(n)]
for i in range(m):
  inp=list(map(lambda x:int(x)-1,input().split()))
  r[inp[0]].append(inp[1])
  r[inp[1]].append(inp[0])

w=[0 for i in range(n)]
w[0]=1
a=[0]
b=[]
while True:
  for i in a:
    for j in r[i]:
      if w[j]==0:
        w[j]=i+1
        b.append(j)
  if len(b)==0:
    break
  a=b
  b=[]
print("Yes")
for i in range(1,n):
  print(w[i])

Measured memory_bytes: 36708
from collections import Counter
N = int(input())
a = [min(8, int(x) // 400) for x in input().split()]
cnt = Counter(a)

min_col = 0     # レート3200未満の人の色の数
for i in range(8):
    if cnt[i]:
        min_col += 1

if min_col == 0:  # 全員3200以上
    min_col = 1
    max_col = N
else:
    max_col = min_col + cnt[8]

print(min_col, max_col)

Measured memory_bytes: 9400