akhauriyash/Code-Regression huggingface dataset:
// Ver19.02
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  ll n, x, m, smallest = INF;
  scanf("%lld%lld", &n, &x);
  for (int i = 0; i < n; i++)
  {
    scanf("%lld", &m);
    x -= m;
    smallest = MIN(smallest, m);
  }
  printf("%lld\n", n + x / smallest);
  return 0;
}

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

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



Measured memory_bytes: 3120
mod = 10**9 + 7
from collections import deque

def main():
    N = iip(False)
    A = iip(True)

    result = [0] * (N+2)
    ans = []

    for i in range(N, 0, -1):
        s = sum(result[i::i])
        if s % 2 != A[i-1]:
            result[i] = 1


    print(sum(result))

    #print(result)
    for i, res in enumerate(result):
        if res == 1:
            ans.append(i)
    split_print_space(ans)


#####################################################ライブラリ集ここから

def split_print_space(s):
    print(" ".join([str(i) for i in s]))

def split_print_enter(s):
    print("\n".join([str(i) for i in s]))


def searchsorted(sorted_list, n, side):
    if side not in ["right", "left"]:
        raise Exception("sideはrightかleftで指定してください")

    l = 0
    r = len(sorted_list)

    if n > sorted_list[-1]:
        #print(sorted_list)
        return len(sorted_list)
    if n < sorted_list[0]:
        return 0

    while r-l > 1:
        x = (l+r)//2
        if sorted_list[x] > n:
            r = x
        elif sorted_list[x] < n:
            l = x
        else:
            if side == "left":
                r = x
            elif side == "right":
                l = x

    if side == "left":
        if sorted_list[l] == n:
            return r - 1
        else:
            return r

    if side == "right":
        if sorted_list[l] == n:
            return l + 1
        else:
            return l


def iip(listed):
    ret = [int(i) for i in input().split()]
    if len(ret) == 1 and not listed:
        return ret[0]
    return ret

def soinsuu_bunkai(n):
    ret = []
    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):
    if n <=0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n-r+1, n+1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r+1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        #print(f"{n}C{r} = {ret}")
        pass
    return ret


def inv(n, mod):
    return power(n, mod-2)

def power(n, p):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p//2) ** 2) % mod
    if p % 2 == 1:
        return (n * power(n, p-1)) % mod


if __name__ == "__main__":
    main()

Measured memory_bytes: 20148
#include<stdio.h>
int main(void){
  int i=0,j=0,z=0,m=0,n=0,Nmin=0,Nmax=0,p[200];
  int gya[200],count=0,goukaku[200],max=0;
  
  for(int o=0;o<200;o++){
    goukaku[o]=0;  
  }
  
  while(1){
    scanf("%d %d %d",&m,&Nmin,&Nmax);
    
    if(m==0 && Nmin==0 && Nmax==0){
      break;
    }
    
    for(int o=0;o<m;o++){
      p[o]=0;
      gya[o]=0;
    }
    
    for(i=0;i<m;i++){
      scanf("%d",&p[i]);
    }
    for(j=Nmin-1;j<Nmax;j++){
      gya[j] = p[j] - p[j+1];
    }
    max=gya[Nmin-1];
    goukaku[count]=Nmin-1;
    for(j=Nmin;j<Nmax;j++){
      if(gya[j]>=max){
	max=gya[j];
	goukaku[count]=j;
      }
    }
    count++;
  }
  
   
  for(i=0;i<count;i++){
    printf("%d\n",goukaku[i]+1); 
  }
  
  
}



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

int main(){
  string n;
  cin >> n;
  if( n.at(0) == n.at(2) ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


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

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 10004;
const int K = 102;
const int mod = (int) 1e9 + 7;

string s;
int n, k;
int dp[N][K][2];

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> s >> k;
	n = SZ(s);
	dp[n][0][0] = dp[n][0][1] = 1;
	for (int idx = n - 1; idx >= 0; idx--) {
		int val = s[idx] - '0';
		for (int sum = 0; sum < k; sum++) {
			for (int mustLess = 0; mustLess < 2; mustLess++) {
				for (int i = 0; i < val; i++)
					(dp[idx][sum][mustLess] += dp[idx + 1][(sum + i) % k][0]) %= mod;
				(dp[idx][sum][mustLess] += dp[idx + 1][(sum + val) % k][mustLess]) %= mod;
				if (!mustLess) {
					for (int i = val + 1; i < 10; i++)
						(dp[idx][sum][mustLess] += dp[idx + 1][(sum + i) % k][0]) %= mod;
				}
			}
		}
	}
	int res = 0;
	for (int i = 0; i < s[0] - '0'; i++)
		(res += dp[1][i % k][0]) %= mod;
	(res += dp[1][(s[0] - '0') % k][1]) %= mod;
	cout << (res - 1 + mod) % mod << endl;
	return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define INFll (1LL << 60)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    int n;
    string s, t;
    cin >> n >> s >> t;

    string ans = "";
    rep(i, n) {
        ans += s[i];
        ans += t[i];
    }
    cout << ans << '\n';    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
int get(int x,int v){return (x>>v)&1;}
int main(){
    DRI(n);
    int res=0;
    set<int>H;
    REP(i,n){
        DRI(x);
        res^=x;
        H.insert(x^(x-1));
    }
    int an=0;
    REP(i,30){
        if((get(res,i)!=get(res,i+1))){
            if(!H.count((1<<(i+1))-1))return 0*puts("-1");
            an++;
        }
    }
    printf("%d\n",an);
    return 0;
}


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

#define N_MAX 105
#define INF (1 << 21)

long P[N_MAX];
long dp[N_MAX][N_MAX];

int main() {
    long n;
    cin >> n;
    for (long i = 0; i < n; i++) {
        cin >> P[i] >> P[i + 1];
    }

    for (long i = 1; i <= n; i++) {
        dp[i][i] = 0;
    }

    for (long l = 1; l <= n - 1; l++) {
        for (long i = 1; i + l <= n; i++) {
            long j = i + l;
            dp[i][j] = INF;
            for (long k = i; k <= j; k++) {
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] + P[i - 1] * P[j] * P[k]);
            }
        }
    }

    cout << dp[1][n] << endl;

    return 0;
}



Measured memory_bytes: 3160
#include<stdio.h>
#include<math.h>
int main ()
{
    int i,j;
    scanf("%d%d",&i,&j);
    if((i+j)%2==0)
    {
        printf("%d\n",(i+j)/2);
    }
    else printf("IMPOSSIBLE\n");

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <limits>
typedef long long ll;
#define REP(i,n)   for(int i=0; i<(int)(n); ++i)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); ++i)

#define in cin
#define out cout
#define pb push_back
using namespace std;

int main(){
	int a[3], b[2];
	REP(i, 3)in >> a[i];
	REP(i, 2)in >> b[i];
	int ans = min(min(a[0],a[1]),a[2]) + min(b[0],b[1]) - 50;
	out << ans<<endl;
	return 0;

}

Measured memory_bytes: 3056
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define st first
#define sc second
#define arr array
#define yes cout << "Yes" <<"\n"
#define no cout << "No" <<"\n"
#define lb lower_bound
#define ub upper_bound
#define fast ios_base::sync_with_stdio(false)
#define out cin.tie(nullptr)
#define task "A"
#define open(task)  if(fopen(task".inp", "r")){freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout);}
#define open_to_check(task)  if(fopen(task".inp", "r")){freopen(task".inp", "r", stdin);}
#define int64 long long

const int maxn = 3e5 + 2;
const int maxN = 1e5 + 5;
const ll mod = 1e9 + 7;

using namespace std;

/// Count : 1

ll a[maxn];


int main()
{
    //if(fopen(task".inp", "r")){
        //freopen(task".inp", "r", stdin);
        //freopen(task".out", "w", stdout);
    //}
    int n;
    cin >> n;
    ll sum = 0;
    ll ans = 0;
    for(int i=1; i<=n; i++){
        cin >> a[i];
        ans += (sum * a[i])%mod;
        ans %= mod;
        sum += a[i];
        sum %= mod;
    }
    cout << ans;
}


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

typedef char String[1024];

int main(void)
{
    String str_a, str_b, str_c;
    scanf("%s %s %s", str_a, str_b, str_c);
    
    int a = atoi(str_a);
    int b = atoi(str_b);
    int c = atoi(str_c);
    
    if (a < b && b < c)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return (0);
}


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

int main() {
  int n, a;
  scanf("%d", &n);
  vector<int> o(n);
  for(int i = 0; i < n - 1; i++) {
    scanf("%d", &a);
    o[a - 1]++;
  }
  for(int i = 0; i < n; i++) printf("%d\n", o[i]);
}

Measured memory_bytes: 4092
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int L = sc.nextInt();
		String[] s = new String[N];
		for(int i=0; i<N; i++){
			s[i] = sc.next();
		}
		for(int i=0; i<N; i++){
			for(int j=N-1; j>i; j--){
				if(s[j].compareTo(s[j-1])<0){
					String exc = s[j];
					s[j] = s[j-1];
					s[j-1] = exc;
				}
			}
			System.out.print(s[i]);
		}
		System.out.println("");
	}
}

Measured memory_bytes: 22868
def main():
    N, K = map(int, input().split())
    if abs(N-((N // K)*K)) < abs(N-(((N // K)+1)*K)):
        print(abs(N-((N // K)*K)))
    else:
        print(abs(N-(((N // K)+1)*K)))
    return 0


if __name__ == '__main__':
    main()

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define maxs(a,b) a=max(a,b)
#define mins(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){
   
    int m1,m2,d1,d2;cin>>m1>>d1>>m2>>d2;

    if(m1+1==m2)cout<<1<<endl;
    else cout<<0<<endl;
    
    return 0;
}

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

int main() {
  int N;
  int ans = 1;
  cin >> N;
  vector<int> mochi(N);
  for (int i=0; i < N; i++) {
    cin >> mochi.at(i);
  }
  sort(mochi.begin(), mochi.end());
  for (int i=1; i < N; i++) {
    if (mochi.at(i) != mochi.at(i - 1)) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//
// Created by yuki on 2018/9/17.
//

#include <iostream>
#include <algorithm>
#include <memory.h>
using namespace std;
typedef  long long ll;
const int N = 105;
int a[N];
int n, x;

int main() {
    cin >> n >> x;
    memset(a, 0, sizeof(a));
    for (int i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + n + 1);
    int ans = 0;
    ll t = x;
    for (int i = 1; i <= n; i++) {
        if (t >= a[i]) {
            t -= a[i];
            ans++;
        } else break;
    }
    if (t > 0 && ans == n) ans--;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  map<int, int> cnt;
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    cnt[a-1]++;
    cnt[a]++;
    cnt[a+1]++;
  }
  int res = 0;
  for(auto p: cnt)
    res = max(p.second, res);
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 4736
#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>;


int main() {

    int r;
    cin >> r;

    double ans = 2 * M_PI * r;
    cout << std::fixed << std::setprecision(15) << ans << endl;



    return 0;
}



Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,i,q;
    cin>>n;
    double a[n],s=0;
    for(i=0;i<n;i++){
        cin>>a[i];
        s=s+(1/a[i]);
    }s=(1/s);
    cout.precision(9);
    cout<<fixed<<s;

return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    double n,k;
    cin>>n>>k;
    for(int i=0;i<n;++i){
    	int a;
    	cin>>a;
    }
    cout<<ceil((n-1)/(k-1));
   return 0;
}

Measured memory_bytes: 3756
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <queue>
#include <functional>

using data = std::tuple<int, int, int, int, int>;

void _fast () { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); }
const std::pair<int, int> delta[4] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
constexpr int dir = 4;
constexpr int INF = (1 << 30);

bool chmin (int &a, int b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

int main() {
	_fast();
	int h, w, k, sx, sy, gx, gy;
	std::cin >> h >> w >> k >> sx >> sy >> gx >> gy;
	sx--; sy--; gx--; gy--;
	std::vector<std::string> s(h);
	for (std::string &e : s) std::cin >> e;
	
	int dist[h][w][dir];
	for (std::size_t i = 0; i < h; i++) {
		for (std::size_t j = 0; j < w; j++) {
			for (std::size_t d = 0; d < dir; d++) {
				dist[i][j][d] = INF;
			}
		}
	}
	for (std::size_t d = 0; d < dir; d++) dist[sx][sy][d] = 0;
	
	std::priority_queue<data, std::vector<data>, std::greater<data>> que;
	for (int i = 0; i < dir; i++) que.emplace(0, k - 1, sx, sy, i);
	
	while (not que.empty()) {
		auto [d, cnt, x, y, idx] = que.top(); que.pop();
		if (dist[x][y][idx] < d) continue;
		
		for (std::size_t i = 0; i < dir; i++) {
			int dx = x + delta[i].first, dy = y + delta[i].second;
			if (dx < 0 or h <= dx or dy < 0 or w <= dy) continue;
			if (s[dx][dy] == '@') continue;
			
			if (idx == i) {
				int cost = 0, nxt = cnt + 1;
				if (nxt >= k) { cost = 1; nxt = 0; }
				if (chmin(dist[dx][dy][i], d + cost)) {
					que.emplace(dist[dx][dy][i], nxt, dx, dy, i);
				}
			} else {
				if (chmin(dist[dx][dy][i], d + 1)) {
					que.emplace(dist[dx][dy][i], 0, dx, dy, i);
				}
			}
		}
	}

	int ans = INF;
	for (std::size_t i = 0; i < dir; i++) {
		chmin(ans, dist[gx][gy][i]);
	}
	
	std::cout << (ans == INF ? -1 : ans) << '\n';

	return 0;
}

Measured memory_bytes: 25264
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;


int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,h,ans=0,a,b;
    cin>>n>>h;
    multiset<pair<ll,bool> > ms;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        ms.insert(make_pair(b,1));
        ms.insert(make_pair(a,0));
    }
    multiset<pair<ll,bool> >::iterator itr,i;
    while(h>0){
        itr=ms.end();
        itr--;
        if((*itr).second){
            h-=(*itr).first;
            ms.erase(itr);
            ans++;
        }
        else{
            ans+=(h+((*itr).first)-1)/((*itr).first);
            break;
        }
    }
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 12800
#include <cstdint>
#include <cstdio>
using namespace std;
#define rep(i, n) for (uint_fast32_t i = 0; i < (n); ++i)
inline char tc() {
    static char fl[100], *A = fl, *B = fl;
    return A == B && (B = (A = fl) + fread(fl, 1, 100, stdin), A == B) ? EOF
                                                                       : *A++;
}
inline uint_fast32_t read() {
    uint_fast32_t a = 0;
    static char c;
    c = tc();
    while (c & 16) a = a * 10 + c - 48, c = tc();
    return a;
}
int h[100001];
int main() {
    uint_fast32_t n = read(), a = read(), b = read();
    a -= b;
    double a_          = 1.0 / a;
    rep(i, n) h[i]     = read();
    uint_fast32_t left = 0, right = 1000000000;
    int_fast64_t temp, cnt        = 0, mid;
    while (right > left + 1) {
        mid = (right + left) >> 1;
        cnt = 0;
        rep(i, n) {
            temp = h[i] - b * mid + a - 1;
            if (temp > 0) cnt += temp * a_;
        }
        if (cnt <= mid)
            right = mid;
        else
            left = mid;
    }
    printf("%u\n", right);
}


Measured memory_bytes: 512
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

n, m = getList()
nums = getList()
n_mods = [0 for i in range(m)]
pair_mods = [0 for i in range(m)]
num_mods = [{} for i in range(m)]

for num in nums:
    modres = num % m
    n_mods[modres] += 1
    if num in num_mods[modres]:
        num_mods[modres][num] += 1
    else:
        num_mods[modres][num] = 1

    if num_mods[modres][num] % 2 == 0:
        pair_mods[modres] += 1

# print(n_mods)
# print(pair_mods)
ans = 0
for i in range(1, (m+1) // 2):
    left = i
    right = m - i
    ans += min(n_mods[left], n_mods[right])
    if n_mods[left] > n_mods[right]:
        ans += max(0, min(pair_mods[left], (n_mods[left] - n_mods[right]) // 2))
    else:
        ans += max(0, min(pair_mods[right], (n_mods[right] - n_mods[left]) // 2))
    # print(left, right, ans)

ans += n_mods[0] // 2
if m % 2 == 0:
    ans += n_mods[m//2] // 2

print(ans)

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

int main() {
    int h, w, d;
    cin >> h >> w >> d;
    vector<pair<int, int>> a(h*w);
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            int aij;
            cin >> aij;
            a[aij-1] = { i, j };
        }
    }

    vector<int> acc(h*w);
    for (int i = 0; i + d < h * w; i++) {
        acc[i+d] = acc[i] + abs(a[i+d].first - a[i].first) + abs(a[i+d].second - a[i].second);
    }

    int q;
    cin >> q;
    vector<pair<int, int>> lr(q);
    for (auto& e : lr) {
        cin >> e.first >> e.second;
        e.first--, e.second--;
    }
    for (auto& e : lr) cout << acc[e.second] - acc[e.first] << endl;
}


Measured memory_bytes: 2944
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repl(i, n) for(LL i = 0; i < (LL)(n); i++)

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

  reverse(s.begin(), s.end());
  reverse(t.begin(), t.end());
  string true_s = s;

  bool exist = false;
  for (int i = 0; i < s.length(); i++) {
    bool match = true;
    for (int j = 0; j < t.length(); j++) {
      if (s[i+j] != t[j] && s[i+j] != '?') {
        match = false;
        true_s = s;
        break;
      } else {
        true_s[i+j] = t[j];
      }
    }
    if (match) {
      exist = true;
      break;
    }
  }

  if (exist) {
    for (int i = 0; i < s.length(); i++) {
      if (true_s[i] == '?') {
        true_s[i] = 'a';
      }
    }
    reverse(true_s.begin(), true_s.end());
    cout << true_s << endl;
  } else {
    cout << "UNRESTORABLE" << endl;
  }

  return 0;
}

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

using namespace std;

void showStr(string str) { cout << str << endl; }
void showInt(int num) { cout << num << endl; }
void showAB(bool isA, string a, string b) {
    if (isA) {
        cout << a << endl;
    } else {
        cout << b << endl;
    }
}
void showYesNo(bool isYes) { showAB(isYes, "Yes", "No"); }
void showYES_NO(bool isYES) { showAB(isYES, "YES", "NO"); }
int getInputToInt() {
    int a;
    cin >> a;
    return a;
}
string getInputToStr() {
    string str;
    cin >> str;
    return str;
}

int main() {
    int n = getInputToInt();
    int k = getInputToInt();

    if(n % k == 0) {
        showInt(0);
    }
    else {
        showInt(1);
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//T+N
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl
 
signed main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ull a, b, c, d, t;
    cin >> a >> b >> c >> d >> t;
    ull dist = labs(a - c);
    ull vel = b - d;
    if(d >= b) {
        cout << "NO" << endl;
    } else if(vel * t >= dist) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}
 

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

int main() {
    int N,K;
    cin >> N >> K;
    vector<int> p(N);
    for(int i=0;i<N;i++) {
        cin >> p.at(i);
    }
    sort(p.begin(),p.end());
    cout << accumulate(p.begin(),p.end()-p.size()+K,0) << endl;
}

Measured memory_bytes: 3584
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>;
using namespace std;
char s[100010];
int main(){
    cin>>s;
    int k=strlen(s);
    if(k%2!=0){
        printf("No");
        return 0;
    }
    for(int i=0;i<k/2;i++){
        int u=abs(s[i]-s[k-i-1]);
        if(u!=1&&u!=2){
            printf("No");
            return 0;
        }
    }
    printf("Yes");
    return 0;
}

Measured memory_bytes: 384
d = dict()
s = int(input())
d[s] = 1
i = 2
n = s

def f(n):
	if n%2==0:
		return n/2
	else:
		return 3*n+1

while True:
	c = f(n)
	if c not in d:
		d[c] = 1
	else:
		print(i)
		quit()
	n = c
	i += 1

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

int main() {
    long long int n, p;
    cin>>n>>p;
    long long int a[n];
    long long int odd = 0;;
    long long int even = 0;
    for(int i = 0;i<n;i++){
        cin>>a[i];
        if(a[i] % 2 != 0){
            odd++;
        } else {
            even++;
        }
    }
    long long int ans = pow(2,(odd+even-1));
    if(even == n && p == 0){
        ans = pow(2, n);
    } else if (even == n && p == 1) {
        ans = 0;
    }
    if ((odd + even - 1) == 0) {
        ans = 0;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
int n;
string s,t;
cin>>n>>s>>t;
char arr[2*n];
for(int i=0;i<n;i++){
  arr[2*i]=s[i];
  arr[2*i+1]=t[i];
}
for(int i=0;i<2*n;i++){
  cout<<arr[i];
}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007

int a,b,c,n,k,x,y;

int main(){
  int ans=0;
  cin >> a >> b;
  int ans0=a+b;
  int ans1=a-b;
  int ans2=a*b;
  ans0=max(ans0,ans1);
  ans0=max(ans0,ans2);


  cout<<ans0<<endl;
  return 0;
}

Measured memory_bytes: 256
require 'prime'
class Integer
  def modinv(m)
    a, b, i, j = self, m, 1, 0
    while b > 0
      t = a / b
      a, b = b, a - t * b
      i, j = j, i - t * j
    end
    return i % m
  end
end

n = gets.to_i
a = gets.split.map(&:to_i)
result = a.inject(&:lcm)%1000000007
a = a.map{|i| (result * i.modinv(1000000007))%1000000007}
puts a.inject{|r,i| (r+i)%1000000007}%1000000007

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

#define all(x) (x).begin(),(x).end()
#define ll long long
#define ld long double
#define pb push_back
#define FR first
#define SC second
#define MOD 1000000007
#define LLMN LONG_LONG_MIN
#define LLMX LONG_LONG_MAX
#define LDMX LDBL_MAX
#define LDMN LDBL_MIN
#define MAX 1000000
#define pll pair<ll, ll>
#define vl vector<ll>
#define vll vector< vl >
#define vb vector<bool>
#define vbb vector< vb >
#define vpl vector<pll>
#define vpll vector< vpl >

void solve()
{
    string s;
    cin>>s;
    vl ind;
    for(ll i = 0; i < 3; i++)
    {
        if(s[i] == 'R')
            ind.pb(i);
    }
    if(ind.size() == 3)
        cout<<3;
    else if(ind.size() == 2)
    {
        if(ind[1] - ind[0] > 1)
            cout<<1;
        else
            cout<<2;
    }
    else
        cout<<ind.size();
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll t = 1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 3652
n = gets.to_i
spots = gets.split.map(&:to_i)
spots << 0
costs = []
previous = 0
spots.each do |spot|
  costs << (previous - spot).abs
  previous = spot
end

costs_when_skipped = []
costs_when_skipped << nil
previous_1 = spots.first
previous_2 = 0
spots[1..n].each do |spot|
  costs_when_skipped << (previous_2 - spot).abs
  previous_2 = previous_1
  previous_1 = spot
end

gaps = []
spots[0...n].each_with_index do |spot, index|
  gaps[index] = costs_when_skipped[index + 1] - (costs[index] + costs[index + 1])
end

costs_sum = costs.inject(:+)

gaps.each do |gap|
  puts costs_sum + gap
end


Measured memory_bytes: 14292
#include <iostream>
#include <iomanip> //setprecision()
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <set>
using ll = long long;
using namespace std;

void monmo(){
    
}

int main() {
    int n;
    int c=0;
    string s;
    cin>>n;
    int nn=n;
    while(n>0){
        n-=1000;
        c++;
    }
    cout<<c*1000-nn;
    return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>

#define Swap(type,a,b) {type tmp = a; a = b; b = tmp ;}

int main(void){
  int X=0,Y=0,Z=0;
  scanf("%d %d %d",&X,&Y,&Z);
  Swap(int,X,Y);
  Swap(int,X,Z);
  printf("%d %d %d\n",X,Y,Z);
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);
    final String[] weather = {"Sunny", "Cloudy", "Rainy"};

    while (in.hasNext()) {
      String S = in.next();

      for (int i = 0; i < weather.length; ++i) {
        if (S.equals(weather[i])) {
          System.out.println(weather[(i + 1) % weather.length]);
        }
      }
    }
  }
}

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


int inum(int N,int W){
    return N/W;
}
int jnum(int N,int W){
    if((N/W)%2) return N%W;
    else return W - (N%W) - 1;
}

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> P(m),Y(m);
    vector<vector<int>> yd(n+1);
    rep(i,m){
        cin >> P[i] >> Y[i];
        yd[P[i]].push_back(Y[i]);
    }

    rep(i,n)sort(yd[i+1].begin(),yd[i+1].end());
    rep(i,m) cout << setw(12) << setfill('0') <<  ll(P[i])*1000000 + int(lower_bound(yd[P[i]].begin(),yd[P[i]].end(),Y[i])-yd[P[i]].begin()+1) << endl;

 }


Measured memory_bytes: 9376
N = int(input())
A = list(map(int, input().split()))

ans = 0


def func(A, flag):
    ans = 0
    acc = 0
    for i in range(0, N):
        acc = acc+A[i]
        if i % 2 == flag:
            if acc >= 0:
                ans += 1+acc
                acc = -1
        else:
            if acc <= 0:
                ans += 1-acc
                acc = 1
    return ans


print(min(func(A, 0), func(A, 1)))


Measured memory_bytes: 14332
#include<bits/stdc++.h>
using namespace std;
#define intl long long int
intl knapsack(intl weight[],intl value[],intl w,intl n,intl dp[][100001])
{
	if(n==0 or w==0)
		return dp[n][w]=0;
    
    if(dp[n][w]!=-1)
        return dp[n][w];
	if(weight[n]>w)
	{
		return dp[n][w]=knapsack(weight,value,w,n-1,dp);
	}else{
		return dp[n][w]=max(value[n]+knapsack(weight,value,w-weight[n],n-1,dp),knapsack(weight,value,w,n-1,dp));
	}

}
int main()
{
	intl n,l;
	cin>>n>>l;
	intl value[101],weight[101];
    intl dp[101][100001];
    for(intl i=0;i<=n;i++)
    {
        for(intl j=0;j<=l;j++)
        {
            dp[i][j]=-1;
        }
    }
    
	for(intl i=1;i<=n;i++)
	{
		cin>>weight[i];
		cin>>value[i];
	}

	cout<<knapsack(weight,value,l,n,dp)<<endl;
}

Measured memory_bytes: 82484
#include<stdio.h>
int main()
{
           long int  n,m,i,sum=0;
           scanf("%ld",&n);
           scanf("%ld",&m);
           long int arr[m];
           for(i=0;i<m;i++)
           {
                   scanf("%ld",&arr[i]);
                   sum+=arr[i];
           }
            if(sum>n)
                  printf("-1");
            else
                  printf("%ld",n-sum);
           return 0;
}


Measured memory_bytes: 1796
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

//--------------------------


int main() {

  int n;
  string s, t;

  cin >> n >> s >> t;

  rep(i, n) {
    cout << s[i] << t[i];
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

ll dp[102][2][5] = {};

int main() {
  string n;
  int k;
  cin >> n;
  cin >> k;
  int len = n.size();
  dp[0][0][0] = 1LL;
  rep(i, len){
    rep(j, 4) { 
        dp[i + 1][1][j] += dp[i][1][j]; //0追加
        dp[i + 1][1][j + 1] += dp[i][1][j] * 9; //1~9追加

        ll ni = n[i] - '0';
        if(ni!=0LL){
          dp[i + 1][1][j] += dp[i][0][j]; //60
          dp[i + 1][1][j + 1] += dp[i][0][j] * (ni - 1LL); //61~62
        }

        if(ni==0LL){
          dp[i + 1][0][j] += dp[i][0][j];
        }else{
          dp[i + 1][0][j + 1] += dp[i][0][j];
        }
    }
  }
  cout << dp[len][1][k] + dp[len][0][k] << endl;
  return 0;
}

Measured memory_bytes: 3576
#include<iostream>
using namespace std;
int main(){
  int h,w,n,a[100001]={},b[100][100];
  cin>>h>>w>>n;
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }
  int cnt=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(a[cnt]==0)cnt++;
      b[i][j]=cnt;
      a[cnt]--;
    }
  }
for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(j)cout<<" ";
      if(i%2==0)cout<<b[i][j];
      else cout<<b[i][w-1-j];
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 768
ARGF.each { |line|
  s = line.chop
  s_size = s.size
  
  keystr = "keyence"

  i = 0
  while (keystr[i] == s[i]) and (i<7)
    i += 1
  end
  j = 1
  while (keystr[7-j] == s[s_size-j]) and (j<=7)
    j += 1
  end

  if i+j > 7
    puts "YES"
  else
    puts "NO"
  end
  exit
}

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n,d; cin >> n >> d;
    int ans = 0;
    d = d * 2 + 1;
    if(n % d == 0) ans += n / d;
    else ans += n / d + 1;
    ANS;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
//#include <math.h>
//#include <stack>
#include <algorithm>
//#include <stdio.h>
#include <cstdio>
using namespace std;
#define rep(i, b) for( int i = 0; i < b; i++ )
#define repi(i, a, b) for( int i = a; i < b; i++ )
typedef vector<int> vec;
#define eps 1e-10

struct C{
    double l, a, b;
};

int N, M;
double ans = 0;
vector<C> c;

/*
double dist( C c1, C c2 ){
    return pow(c1.l - c2.l, 2) + pow(c1.a - c2.a, 2) + pow(c1.b - c2.b, 2);
}*/

double dist( C c1, C c2 ){
    return (c1.l - c2.l)*(c1.l - c2.l) + (c1.a - c2.a)*(c1.a - c2.a) + (c1.b - c2.b)*(c1.b - c2.b);
}

void dfs( int d, vec v ){
    if( d == M ){
        double sum = 0;
        rep(i, v.size()) repi(j, i+1, v.size()){
            sum += dist(c[v[i]], c[v[j]]);
        }
        //cout << 'ans:' << ans << endl;
        ans = max( ans, sum );
    }else{
        repi(i, v[d-1]+1, N){
            v.push_back(i);
            dfs(d+1, v);
            v.pop_back();
        }
    }
}

int main(){
    cin >> N >> M;
    rep(i, N){
        C t;
        cin >> t.l >> t.a >> t.b;
        c.push_back(t);
    }
    vec v;

    rep(i, N){
        v.push_back(i);
        dfs(1, v);
        v.pop_back();
    }
    printf("%.20f\n", ans);
}

Measured memory_bytes: 1272
import sys

d = {'A': 0, 'B': 1, 'C': 2}
cup = [1, 0, 0]

for line in sys.stdin:
  try:
    a, b = [i for i in line.split(',')]
    cup[d[a[0]]], cup[d[b[0]]] = cup[d[b[0]]], cup[d[a[0]]]
  except:
    break
if cup[0] == 1:
  print('A')
elif cup[1] == 1:
  print('B')
else:
  print('C')

Measured memory_bytes: 5572
n = int(input())
A = [int(input()) for _ in range(n)]
a=sorted(A)
# print(n//2)
if n%2:
    print(sum(a[-n//2+1:])*2 - sum(a[:n//2])*2 - min(a[n//2+1]-a[n//2],a[n//2]-a[n//2-1]))
else:
    print(sum(a[n//2+1:])*2 -sum(a[:n//2-1])*2 +a[n//2] -a[n//2-1])

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
//const ll INF = 1LL<<60;
int INF = numeric_limits<int>::max();

int main(int, char**) {
	int h, w; cin >> h >> w;
	vector<vector<int>> dist(10, vector<int>(10, INF));
	vector<int> mind;
	for (int i=0; i<10; i++) {
		for (int j=0; j<10; j++) {
			cin >> dist[i][j];
		}
	}
	for (int i=0; i<10; i++) {
		for (int j=0; j<10; j++) {
			for (int k=0; k<10; k++) {
				dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
			}
		}
	}
	ll ret = 0;
	for (int i=0; i<h*w; i++) {
		int a; cin >> a;
		if (a==-1) continue;
		else ret += dist[a][1];
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int N;
  cin>>N;
  
  vector<string> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec[i];
  }
  
  
  set<string> S;
  
  for(int i=0;i<N;i++){
    S.insert(vec[i]);
  }
  
  cout<<S.size()<<endl;
}

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

struct UnionFind {
  vector<int> par;
  
  UnionFind(int N) {
    par = vector<int>(N, -1);
  }
  
  int root(int x) {
    if (par.at(x) < 0) return x;
    return par.at(x) = root(par.at(x));
  }
  
  bool unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return false;
    if (par.at(rx) > par.at(ry)) swap(rx, ry);
    par.at(rx) += par.at(ry);
    par.at(ry) = rx;
    return true;
  }
  
  int size(int x) {
    return -par.at(root(x));
  }
  
  bool same(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main() {
  int N, M, K;
  cin >> N >> M >> K;
  UnionFind tree(N);
  vector<int> A(M), B(M), C(K), D(K), ans(N);
  for (int i = 0; i < M; i++) {
    cin >> A.at(i) >> B.at(i);
    A.at(i)--;
    B.at(i)--;
    tree.unite(A.at(i), B.at(i));
  }
  for (int i = 0; i < K; i++) {
    cin >> C.at(i) >> D.at(i);
    C.at(i)--;
    D.at(i)--;
  }
  for (int i = 0; i < N; i++) ans.at(i) = tree.size(i) - 1;
  for (int i = 0; i < M; i++) {
    ans.at(A.at(i))--;
    ans.at(B.at(i))--;
  }
  for (int i = 0; i < K; i++) {
    if (tree.same(C.at(i), D.at(i))) {
      ans.at(C.at(i))--;
      ans.at(D.at(i))--;
    }
  }
  for (int i = 0; i < N; i++) cout << ans.at(i) << " ";
  cout << endl;
}

Measured memory_bytes: 5648
#include <vector>
#include <set>
#include <iostream>
#include <unistd.h>

using namespace std;

#define SENTINEL -1

class Stack {
    vector<int> v;
public:
    Stack() {}
    void add(int n) { v.push_back(n); }
    int pick() { int ret = v.back(); v.pop_back(); return ret; }
    int peek() { return v.back(); }
    void pop() { pick(); }

    int size() { return v.size(); }
    int empty() { return size() == 0; }
};

int main() {
    int N, M; cin >> N >> M;
    vector<int> from[N];
    vector<int> to[N];
    for (int i=0; i<M; i++) {
        int f,t;
        scanf("%d %d", &f, &t);
        from[f-1].push_back(t-1);
        to[t-1].push_back(f-1);
    }

    // init ans array with SENTINEL
    vector<int> ans(N, 1);
    vector<bool> calc(N, false);
    
    // unvisited nodes
    set<int> unvisited;
    for (int i=0; i<N; i++) unvisited.insert(i);

    // cout << "here I am" << endl;
    while (!unvisited.empty()) {
        int n = *unvisited.begin();
        Stack s; s.add(n);

        while (!s.empty()) {
            int n = s.peek();
            // sleep(1);
            // cout << "calcing " << n << endl;
            for (int i=0; i<from[n].size(); i++) {
                int t = from[n][i];
                if (!calc[t]) {
                    // cout << "adding for " << n << " node " << t << endl;
                    s.add(t);
                }
            }

            // update time
            if (n == s.peek()) {
                for (int i=0; i<from[n].size(); i++) {
                    ans[n] = max (ans[n], ans[from[n][i]] +1);
                }
                s.pop();
                unvisited.erase(n);
                calc[n] = true;
            }
        }
    }

    int ret = -1;
    for (int i=0; i<ans.size(); i++) 
        ret = max (ret, ans[i]);
    
    cout << ret-1 << endl;

    return 0;
}

Measured memory_bytes: 16656
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    def value(v):
        cnt = 0
        for i in a:
            cnt += (i-1)//v
        if cnt > k:
            return False
        else:
            return True

    def b_search(ok, ng, value):
        while abs(ok-ng) > 1:
            mid = (ok+ng)//2
            if value(mid):
                ok = mid
            else:
                ng = mid
        return ok

    print(b_search(10**16, 0, value))


main()


Measured memory_bytes: 93876
import sys
input = sys.stdin.readline

'''

'''

n = int(input())
a = sorted(map(int, input().split()))
largest = a[-1]
#largest = arr[-1]
div = [1] * (largest+1)
count = 0
arr = []
# remove duplicates
for i, v in enumerate(a):
    if i < (n-1) and a[i+1] == v:
        div[v] = 0
    else:
        arr.append(v)

arr.sort()

for num in arr:
    if div[num]:
        count += 1

    for d in range(num, largest+1, num):
        div[d] = 0

print(count)
    


Measured memory_bytes: 106240
#include <stdio.h>

int main() {
    int a, b, c, k;
    scanf("%d %d %d %d", &a, &b, &c, &k);
    int ans = 0;
    if (k > a) ans += a, k -= a;
    else ans += k, k = 0;
    if (k > b) k -= b;
    else k = 0;
    ans -= k;
    printf("%d\n", ans);
}

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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  int N;
  cin >> N;
  if (N < 105)
  {
    cout << 0 << endl;
    return 0;
  }

  int sum = 0;
  for (int i = 105; i <= N; i++)
  {
    if (i % 2 == 0)
      continue;

    int div = 0;
    for (int j = 1; j <= N; j++)
    {
      if (i % j == 0)
        div++;
    }
    if (div == 8)
      sum++;
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 256
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
//ll a[Max];
ll n,d;
void solve(){
	cin>>n;
	int j=0;
	int mx1=0,mx2=0;
	rep(i,0,n){
		ll t;
		cin>>t;
		if(t>mx1){
			mx1 = t;
			j = i;
		}else if(t>mx2){
			mx2 = t;
		}
	}
	rep(i,0,n)if(i==j)cout<<mx2<<endl;else cout<<mx1<<endl;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





Measured memory_bytes: 1664
import sys
input = sys.stdin.readline
N, M, X, Y = map(int, input().split())
x = [int(x) for x in input().split()]
y = [int(x) for x in input().split()]

if max(x) < min(y) and max(x) < Y and min(y) > X :
    print("No War")
else :
    print("War")


Measured memory_bytes: 2940
// template version 1.13
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int n;cin>>n;
  rep(i, 1, 10){
    rep(j, 1, 10){
      if (i*j==n){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, d: "List[int]"):
    print(len(set(d)))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    d = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, d)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940