akhauriyash/Code-Regression huggingface dataset:
import sys
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from collections import Counter

n = ni()
a = na()

c = Counter(a)
ans = [0] * n
for k, v in c.items():
    ans[k - 1] = v

for i in range(n):
    print(ans[i])

Measured memory_bytes: 35212
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;

long long int DP[20000] = {};

int main()
{
	long long int N, W;
	cin >> N >> W;
	
	vector<P> vec;
	
	for(int i = 0; i < N; i++){
		long long int v, w, m;
		cin >> v >> w >> m;
		P p;
		for(int j = 1; j <= m; j *= 2){
			p.first = v * j;
			p.second = w * j;
			vec.push_back(p);
			m -= j;
		}
		p.first = v * m;
		p.second = w * m;
		vec.push_back(p);
	}
	
	for(int i = 0; i < vec.size(); i++){
		for(int j = W; j >= vec[i].second; j--){
			DP[j] = max(DP[j], DP[j - vec[i].second] + vec[i].first);
		}
	}
	
	cout << DP[W] << endl;
	
	return 0;
}


Measured memory_bytes: 3248
/*Stay true to yourself, yet always be open to learn. Work hard, and never give up on your dreams, 
even when nobody else believes they can come true but you. These are not cliches but real tools you 
need no matter what you do in life to stay focused on your path.
*/

 /*Pppppppp    UU      UU     CCCCCCCC    CCCCCCCC     HH     HH     UU      UU
   pp    pp    UU      UU     CC          CC           HH     HH     UU      UU
   pp    pp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
   pppppppp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
   pp          UU      UU     CC          CC           HH     HH     UU      UU
   pp          UUUUUUUUUU     CCCCCCCC    CCCCCCCC     HH     HH     UUUUUUUUUU
   */

#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
     cin>> n;
     int a[n],b[n];
     for(int i=0;i<n;i++)
     {
         cin >> a[i];
         b[i] = a[i];
     }
     sort(b,b+n);
     int f=0;
     for(int i=0;i<n;i++){
         if(b[i]!=a[i])
         f++;
     }
     if(f==0)
     cout<<"YES";
     else
     if(f==2)
     cout<<"YES";
     else
     cout<<"NO";
    return 0;
}

Measured memory_bytes: 256
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

A,B,C,D = LI()

while 1:
    C -= B
    if C <= 0:
        print('Yes')
        exit()
    A -= D
    if A <= 0:
        print('No')
        exit()

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

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

  map<string, int> playlist;
  string title;
  int N, minutes, sum = 0;

  cin >> N;
  for (int i = 0; i < N; i++)
  {
    cin >> title >> minutes;
    sum += minutes;
    playlist[title] = sum;
  }

  cin >> title;
  cout << sum - playlist[title] << endl;
  
  return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    int h, w;
    cin>>h>>w;
    vector<string> grid(h);
    cin>>grid;

    int cnt = 0;
    rep(i, h) rep(j, w) if (grid[i][j] == '#') cnt++;
    if (cnt == h + w - 1) cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int n;
long long a,b,s[100005];
struct tree{
	int l,r,sum,bj;
}t[2][800005];
int to[2][100005];

long long read(){
	long long x=0;char ch=getchar();
	while(!isdigit(ch)) ch=getchar();
	while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return x;
}

void build(int id,int x,int l,int r){
	t[id][x].l=l,t[id][x].r=r;
	t[id][x].bj=-1;
	if(l==r){
		t[id][x].sum=(l==1);
		return;
	}
	int mid=(l+r)/2;
	build(id,2*x,l,mid);
	build(id,2*x+1,mid+1,r);
	t[id][x].sum=t[id][2*x].sum+t[id][2*x+1].sum;
}

void pushdown(int id,int x){
	t[id][x].sum=1ll*t[id][x].bj*(t[id][x].r-t[id][x].l+1)%mod;
	t[id][2*x].bj=t[id][x].bj;
	t[id][2*x+1].bj=t[id][x].bj;
	t[id][x].bj=-1;
}

void updata(int id,int x,int l,int r,int y){
	if(t[id][x].bj!=-1) pushdown(id,x);
	if(t[id][x].l>r||t[id][x].r<l) return;
	if(t[id][x].l>=l&&t[id][x].r<=r){
		t[id][x].bj=y;
		pushdown(id,x);
		return;
	}
	updata(id,2*x,l,r,y);
	updata(id,2*x+1,l,r,y);
	t[id][x].sum=t[id][2*x].sum+t[id][2*x+1].sum;
	if(t[id][x].sum>=mod) t[id][x].sum-=mod;
}

int query(int id,int x,int l,int r){
	if(t[id][x].bj!=-1) pushdown(id,x);
	if(t[id][x].l>r||t[id][x].r<l) return 0;
	if(t[id][x].l>=l&&t[id][x].r<=r) return t[id][x].sum;
	int res=0;
	res=query(id,2*x,l,r)+query(id,2*x+1,l,r);
	if(res>=mod) res-=mod;
	return res;
}

int main(){
	n=read(),a=read(),b=read();
	for(int i=1;i<=n;i++) s[i]=read();
	build(0,1,1,n);
	build(1,1,1,n);
	int l=0,l1=0;
	for(int r=1;r<=n;r++){
		while(s[l+1]+a<=s[r]&&l<n) l++;
		to[0][r]=l;
		while(s[l1+1]+b<=s[r]&&l1<n) l1++;
		to[1][r]=l1;
	}
	for(int i=2;i<=n;i++){
		int end1=query(1,1,1,min(i-1,to[0][i]+1));
		int end2=query(0,1,1,min(i-1,to[1][i]+1));
		if(s[i]-s[i-1]<a) updata(0,1,1,i-1,0);
		if(s[i]-s[i-1]<b) updata(1,1,1,i-1,0);
		updata(0,1,i,i,end1);
		updata(1,1,i,i,end2);
	}
	int ans=query(0,1,1,n)+query(1,1,1,n);
	if(ans>=mod) ans-=mod;
	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 21504
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
from typing import List
from collections import Counter


def get_no_dupes(arr: List[int]) -> List[int]:
    cntr = Counter(arr)
    ret = []
    for elem in cntr:
        if cntr[elem] == 1:
            ret.append(elem)
    return ret


def main() -> None:
    input()

    arr = list(map(int, input().split()))

    busted = [False] * (10 ** 6 + 10)

    seen = set()
    max_limit = 10 ** 6
    for num in arr:
        if num in seen:
            continue
        for i in range(2 * num, max_limit + 1, num):
            busted[i] = True
        seen.add(num)

    arr = get_no_dupes(arr)
    cnt = 0
    for num in arr:
        if not busted[num]:
            cnt += 1

    print(cnt)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self, **kwargs):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 165692
#include <bits/stdc++.h>
     
    using namespace std;
     
    const int MN = 1e5+10;
    typedef long long ll;
    typedef pair<int,int> ii;
     
    int main()
    {
        #ifdef ACMTUYO
        freopen("a.in","r",stdin);
        #else
        cin.tie(0); ios_base::sync_with_stdio(0);
        #endif
     
        long long a,b,x,res=0;
        cin >> a >> b >> x;

        if (a == 0) {res = 1; a=1;}

        res+=(b/x - (a-1)/x);
        cout << res << "\n";
     
        return 0;
    }

Measured memory_bytes: 384
import numpy as np
H, W = map(int, input().split())
mp = np.array([list(input()) for _ in range(H)], dtype=str)

import queue
q = queue.Queue()
visit = (mp == "#")

def can_visit(x, y):
    """訪問可能ならTrue。壁、既訪問、世界外ならFalse"""
    if x < 0 or y < 0 or x >= W or y >= H:
        return False
    return not visit[y, x]

def push_neighbor(x, y, d):
    """隣接マスをキューにpush"""
    lis = [(x+1, y), (x-1, y), (x, y+1), (x, y-1)]
    for nx, ny in lis:
        if can_visit(nx, ny):
            q.put((nx, ny, d+1))
            visit[ny, nx] = True

def furthest(sx, sy):
    """位置(sx, sy)から見て一番遠い場所までの距離"""
    # 初期化
    global visit
    visit = (mp == "#")
    if visit[sy, sx]:# 例外処理(スタート地点が壁の中)
        return 0
    visit[sy, sx] = True# 初期位置は訪問済み
    # 計算
    q.put((sx, sy, 0))
    while not q.empty():
        x, y, d = q.get()
        push_neighbor(x, y, d)
    return d

dist = max([furthest(sx, sy) for sx in range(W) for sy in range(H)])
print(dist)

Measured memory_bytes: 13116
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	ll N;
	cin >> N;
	vector<ll> a(100002);
	rep(i, N) {
		ll A;
		cin >> A;
		a.at(A)++;
	}
	ll an = 0;

	rep(i, 100000) {
		an = max(an, a.at(i) + a.at(i+1) + a.at(i+2));
	}
	cout << an << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};

int32_t main(){

    string s;
    cin>>s;
    for(char&c:s){
        if(c=='?'){
            c='D';
        }
    }
    cout<<s<<'\n';

    return 0;
}


Measured memory_bytes: 3780
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)

	ss := strings.Split(s, "")

	r := []string{}
	for _, s := range ss {

		if "B" == s {
			if len(r) != 0 {
				r = r[:len(r)-1]
			}
		} else {
			r = append(r, s)
		}
	}

	result := ""
	for _, rr := range r {
		result += rr
	}
	fmt.Print(result)
}


Measured memory_bytes: 640
//#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int N = 1000 + 5;
const int M = 201;
const int Q = 2e5 + 5;
const int OO = 2e9;
const int mod = 998244353;

string a,b;

void init() {
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> a >> b;

    bool ok = 1;

    for (int i = 0; i < a.size(); ++i) {
        if(a[i]!=b[i]) ok = 0;
    }

    cout << (ok ? "Yes" : "No") << '\n';

    return 0;
}


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

using namespace std;

#define maxn 100005
#define ll long long int
#define db(x) cout<<#x<<" ->"<<x<<endl
#define db2(x,y) cout<<#x<<"->"<<x<<", "<<#y<<" -> "<<y<<endl
#define db3(x,y,z) cout<<#x<<" -> "<<x<<" , "<<#y<<" -> "<<y<<" , "<<#z<<" -> "<<z<<endl
#define prt(x) for(auto it = x.begin(); it!=x.end(); it++) { cout<<*it<<" "; } cout<<endl
#define IN freopen("input.txt","r",stdin)

int dp[maxn];
int arr[maxn];
int n;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
  //  IN;
  //  memset(dp,-1,sizeof(dp));
    cin>>n;
    for(int i=1; i<=n; i++){
        cin>>arr[i];
    }
    dp[1] = 0;
    dp[2] = abs(arr[1]-arr[2]);
    for(int i=3; i<=n; i++){
        dp[ i ] = min(dp[i-1] + abs(arr[i-1]-arr[i]) , dp[i-2]+abs(arr[i-2]-arr[i]));
    }
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 1024
#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<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//CODE

void solve(void)
{
  int N;
  cin>>N;
  vector<int> data (3,0);
  for (int i = 0; i < N; i++)
  {
    int A;
    cin>>A;
    if(A%4 ==0)
    {
      data[0] ++;
    }
    else if(A%2 == 0)
    {
      data[1]++;
    }
    else
    {
      data[2]++;
    }

    
  }
    bool check = true;
    if(data[0] -1*data[2] -1*data[1]%2 +1< 0 ) check = false;
    cout<<(check?"Yes":"No")<<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(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp std::make_pair
#define pb push_back
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::set<int> si;
typedef std::string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int N;
ll L;
ll a[100010];
int main(){
  cin>>N>>L;
  rep(i,N) cin>>a[i];
  ll kn[100010];
  ll max=0;
  int j=0;
  rep(i,N-1){
    kn[i]=a[i]+a[i+1];
    if(max<kn[i]){
      max=kn[i];
      j=i;
    }
  }
  if(max>=L){
    prin("Possible");
    int k=0;
    while(k!=j){
      prin(k+1);
      k++;
    }
    k=N-2;
    while(k!=j){
      prin(k+1);
      k--;
    }
    prin(j+1);
  }
  else prin("Impossible");
  return 0;
}


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

int n,m,q,a[50],b[50],c[50],d[50],ans;
int p[10];

void dfs(int len,int pre){
    if(len==n){
        int sum=0;
        for(int i=0;i<q;i++) 
		if(p[b[i]-1]-p[a[i]-1]==c[i]) 
		sum+=d[i];
        ans=max(ans,sum);
        return;
    }
    for(int i=pre;i<=m;i++){
        p[len]=i;
        dfs(len+1,i);
    }
}

int main()
{
    cin>>n>>m>>q;
    for(int i=0;i<q;i++) 
	cin>>a[i]>>b[i]>>c[i]>>d[i];
    dfs(0,1);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <stack>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

bool is_bi_graph(int N, vector<vector<int>> all_es) {
    vector<int> colors(N, -1);
    stack<int> nodes;
    colors[0] = 0;
    nodes.push(0);
    while (!nodes.empty()) {
        int n = nodes.top();
        nodes.pop();
        int c = colors[n];
        int diff_c = c == 0 ? 1 : 0;
        for (int i = 0; i < N; ++i) {
            int cn = all_es[n][i];
            if (cn == 0) continue;
            int other_c = colors[i];
            if (other_c == c) return false;
            if (other_c == -1) {
                colors[i] = diff_c;
                nodes.push(i);
            }
        }
    }
    return true;
}

const int INF = 100000;
int calc_max_d(int N, vector<vector<int>> all_es) {
    vector<vector<int>> ds(N, vector<int>(N, 0));
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if (i == j) {
                ds[i][j] = 0;
            } else {
                int c = all_es[i][j];
                ds[i][j] = c == 0 ? INF : 1;
            }
        }
    }
    for (int k = 0; k < N; ++k) {
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                int d1 = ds[i][j];
                int d2 = ds[i][k];
                int d3 = ds[k][j];
                int d = min(d1, d2 + d3);
                ds[i][j] = d;
            }
        }
    }
    int max_d = 0;
    for (int i = 0; i < N - 1; ++i) {
        for (int j = i + 1; j < N; ++j) {
            int d = ds[i][j];
            if (d < INF && d > max_d) max_d = d;
        }
    }
    return max_d;
}

int main() {
    int N;
    cin >> N;
    vector<vector<int>> all_es(N, vector<int>(N, 0));
    for (int i = 0; i < N; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < N; ++j) {
            char c = s[j];
            all_es[i][j] = c - '0';
        }
    }
    if (!is_bi_graph(N, all_es)) {
        cout << "-1\n";
        return 0;
    }
    int d = calc_max_d(N, all_es);
    cout << (d + 1) << "\n";
    return 0;
}

Measured memory_bytes: 736
import java.util.*;
import java.math.BigDecimal;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int L = scan.nextInt();
		BigDecimal a = BigDecimal.valueOf(L);
		BigDecimal b = BigDecimal.valueOf(27);
		BigDecimal sum = a.multiply(a.multiply(a));
		BigDecimal ans = sum.divide(b, 7, BigDecimal.ROUND_HALF_UP);

		System.out.println(ans);
	}
}

Measured memory_bytes: 23124
fun main(args: Array<String>) {
val num = readLine()

val numS=num.toString()
if(numS.endsWith("2")||numS.endsWith("4")||numS.endsWith("5")||numS.endsWith("7")||numS.endsWith("9")){
println("hon")
}else if(numS.endsWith("0")||numS.endsWith("1")||numS.endsWith("6")||numS.endsWith("8")){
println("pon")
}else if(numS.endsWith("3")){
println("bon")
}
}

Measured memory_bytes: 35816
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }

//小数点以下を切り上げる割り算
ll updivide(ll a,ll b){
    if(b==1) return a;
    else if(a%b==0) return a/b;
    else return (a/b)+1;
}

int main(){
    LL(n,h);
    vector<pair<ll,ll>> vec(n);
    vector<ll> a(n),b(n);
    ll maxv=0;
    rep(i,n){
        in(a[i],b[i]);
        if(a[i]>maxv){
            maxv=a[i];
        }
    }
    sort(rall(b));
    int i=0,ans=0;
    while(b[i]>=maxv&&h>0){
        h-=b[i];
        ans++;
        i++;
    }
    if(h>0)ans+=(int)updivide(h,maxv);
    out(ans);
}

Measured memory_bytes: 6448
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define SREP(s,i,m) for(unsigned int i = s; i < m; ++i)
#define REP(i,m) SREP(0,i,m)

using namespace std;
#ifdef _MSC_VER
using LONG = __int64;
using ULONG = unsigned __int64;
#else
using LONG = long long int;
using ULONG = unsigned long long int;
#endif

struct coord {
	int x, y;
	bool operator<(const coord &right) const {
		return y == right.y ? x < right.x : y < right.y;
	}
	bool operator==(const coord &right) const {
		return y == right.y && x == right.x;
	}
	bool operator<=(const coord &right) const {
		return *this == right || *this < right;
	}
};

int main(void) {
	int N, K;
	vector<coord> ps;
	set<int> xset;
	set<int> yset;
	cin >> N >> K;
	ps.resize(N);
	REP(i, N) {
		cin >> ps[i].x >> ps[i].y;
		xset.insert(ps[i].x);
		yset.insert(ps[i].y);
	}
	sort(ps.begin(), ps.end());
	vector<int> xs, ys;
	for (auto x : xset) {
		xs.push_back(x);
	}
	for (auto y : yset) {
		ys.push_back(y);
	}
	sort(xs.begin(), xs.end());
	sort(ys.begin(), ys.end());
	vector<vector<int>> dp;
	dp.resize(ys.size());
	REP(i, dp.size()) dp[i].resize(ys.size(), 0);
	int idx = 0;

	for (int i = 0; i < ys.size(); i++) {
		for (int j = 0; j < xs.size(); j++) {
			coord c = { xs[j], ys[i] };
			bool inc = false;
			if (idx < ps.size() && ps[idx] == c) inc = true;
			if (inc) idx++;
			dp[i][j] = (j - 1 >= 0 ? dp[i][j - 1] : 0)
				+ (i - 1 >= 0 ? dp[i - 1][j] : 0)
				- (i - 1 >= 0 && j - 1 >= 0 ? dp[i - 1][j - 1] : 0) + (inc ? 1 : 0);
		}
	}
	LONG minS = (LONG)2000000000 * (LONG)2000000000;
	for (int xmin = 0; xmin < xs.size() - 1; xmin++) {
		for (int xmax = xmin + 1; xmax < xs.size(); xmax++) {
			for (int ymin = 0; ymin < ys.size() - 1; ymin++) {
				for (int ymax = ymin + 1; ymax < ys.size(); ymax++) {
					int num = dp[ymax][xmax]
						+ (ymin - 1 >= 0 && xmin - 1 >= 0 ? dp[ymin-1][xmin-1] : 0)
						- (ymin - 1 >= 0 ? dp[ymin-1][xmax] : 0)
						- (xmin - 1 >= 0 ? dp[ymax][xmin - 1] : 0);
					if (num >= K) {
						minS = min(minS, (LONG)(xs[xmax] - xs[xmin]) * (LONG)(ys[ymax] - ys[ymin]));
					}
				}
			}
		}
	}
	cout << minS << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n, k;
    cin >> n >> k;
    
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    vector<int> b(k + 1, -1);
    for (int j = 0; j <= k; j++) {
        if (b[j] >= 0) continue;
        for (int i = 0; i < n; i++) {
            if (j - a[i] < 0) continue;
            if (b[j - a[i]] == 1) {
                b[j] = 0;
                break;
            }
        }
        if (b[j] < 0) b[j] = 1;
    }

    cout << (b[k] == 0 ? "First" : "Second") << endl;

    return 0;
}

Measured memory_bytes: 640
#include <cstdio>

const int maxn=200000;

int read()
{
  int x=0,f=1;
  char ch=getchar();
  while((ch<'0')||(ch>'9'))
    {
      if(ch=='-')
        {
          f=-f;
        }
      ch=getchar();
    }
  while((ch>='0')&&(ch<='9'))
    {
      x=x*10+ch-'0';
      ch=getchar();
    }
  return x*f;
}

int n,a[maxn+10],t[maxn+10][23],now[23];
long long ans;

inline int trans(int v,int pos)
{
  int x=1;
  while(v)
    {
      t[pos][x]=v%2;
      ++x;
      v/=2;
    }
  return 0;
}

inline int check(int pos)
{
  for(int i=1; i<=20; ++i)
    {
      if(now[i]&&t[pos][i])
        {
          return 0;
        }
    }
  return 1;
}

int main()
{
  n=read();
  for(int i=1; i<=n; ++i)
    {
      a[i]=read();
      trans(a[i],i);
    }
  int r=1;
  for(int i=1; i<=20; ++i)
    {
      now[i]=t[1][i];
    }
  for(int l=1; l<=n; ++l)
    {
      for(int i=1; i<=20; ++i)
        {
          now[i]^=t[l-1][i];
        }
      while((r<n)&&(check(r+1)))
        {
          ++r;
          for(int i=1; i<=20; ++i)
            {
              now[i]|=t[r][i];
            }
        }
      ans+=r-l+1;
    }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 18944
#include <stdio.h>

int main(void){
    int n,m,i;
    int a[100];
    i = 0;
    scanf("%d",&n);
    while(i<n){
        scanf("%d",&a[i]);
        i++;
    }
    for(i = n-1;i>=0;i--){
        if(i == 0){
        printf("%d\n", a[0]);
        }
        else{
            printf( "%d ",a[i]);
        }
    }
    return(0);
}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <cstring>
//#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define de(x,y) cout<<#x<<" :"<<x<<y;
#define int long long
#define SZ(xx) ((int)xx.size())
#define lowbit(xx) (xx&(-xx))
#define pb push_back
typedef pair<int,int> pii;

const int maxn = 3e2+5;

double dp[maxn][maxn][maxn] = {};
double tmp[maxn * 3][maxn] = {};


main() {
	int n;
	cin >> n;
	int sum = 0, cnt[5] = {};
	for (int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		sum += x;
		cnt[x]++;
	}
	dp[cnt[3]][cnt[2]][cnt[1]] = 1;
	for (int i = cnt[3]; i >= 0; i--) {
		for (int j = cnt[3] + cnt[2]; j >= 0; j--) {
			for (int k = cnt[1] + cnt[2] + cnt[3]; k >= 0; k--) {
				if (dp[i][j][k]) {
					tmp[i * 3 + j * 2 + k][n - i - j - k] += dp[i][j][k];
					if (i >= 1)
					dp[i-1][j+1][k] = dp[i-1][j+1][k] + dp[i][j][k] * i / (i + j + k);
					if (j >= 1)
					dp[i][j-1][k+1] = dp[i][j-1][k+1] + dp[i][j][k] * j / (i + j + k);
					if (k >= 1)
					dp[i][j][k-1] += (dp[i][j][k] * k) / (i + j + k); 
//					cout << i << " " << j << " " << k << " " << dp[i][j][k] << "\n"; 
				}
			}
		}
	} 
	double ans = 0;
	for (int i = sum; i >= 1; i--) {
		double All = 0;
		for (int j = 0; j < n; j++) {
			All += tmp[i][j];
//			cout << tmp[i][j] << " \n"[j==n-1];
		}
		if (!All) continue;
		for (int j = 0; j < n; j++) {
			ans = ans + ((double)tmp[i][j] / All) * (double)n / ((double)n - (double)j);
		}
	
	}
//	cout << ans << "\n";
	printf("%.9f\n", ans);
}


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

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

using lli = long long int;
using pii = std::pair<int, int>;

template <class T> inline bool chmax(T& a, T b){
    if(a < b){a = b; return true;}
    return false;
}
template <class T> inline bool chmin(T& a, T b){
    if(a > b){a = b; return true;}
    return false;
}


using Pii = std::pair<int, int>;

std::vector<Pii> A;
std::vector<int> Y;

int main(void){
    int n, k; scanf("%d%d", &n, &k);

    A.resize(n);
    REP(i, n){
        int x, y; scanf("%d%d", &x, &y);
        A[i] = Pii(x, y);
    }

    lli ans = LLONG_MAX;

    std::sort(A.begin(), A.end());

    for(int xS = 0; xS < n; ++xS){
        for(int t = k; xS + t <= n; ++t){
            int xE = xS + t;
            lli dX = A[xE-1].first - A[xS].first;

            for(int i = xS; i < xE; i++) Y.push_back(A[i].second);
            std::sort(Y.begin(), Y.end());
            
            const int m = Y.size();
            lli dY = LLONG_MAX;
            for(int yS = 0; yS + k <= m; ++yS){
                int dk = Y[yS + k - 1] - Y[yS];
                chmin(dY, (long long)dk);
            }

            Y.clear(); // 一旦クリア

            chmin(ans, dX*dY);

        }

    }
    
    printf("%lld\n", ans);    



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define llu unsigned long long
#define U unsigned int
#define SIZE 1000002
#define pie 3.14159265358979323
#define minuss 1e-6
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

ll summ(ll t, ll sum)
{
    if(t==1)
    {
        sum=sum+1;
        return sum;
    }
    else
    {
        sum=sum+(2*(summ(t/2,sum))+1);
        return sum;
    }
}
int main()
{
        ll t;
        cin>>t;
        ll sum=0;
        ll tot=summ(t,sum);
        cout<<tot<<endl;

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    struct Position { internal int x, y, depth; }

    class Puzzle
    {
        readonly int[] moveX = new int[] { -2, -2, -2, -1,  0, +1, +2, +2, +2, -1,  0, +1 };
        readonly int[] moveY = new int[] { -1,  0, +1, -2, -2, -2, -1,  0, +1, +2, +2, +2 };

        readonly int n;

        bool[,,] map;
        
        public Puzzle(int n)
        {
            this.n = n;
            map = new bool[n, 10, 10];
        }
        
        public void MakeMap(int depth,int x,int y)
        {
            Position p;
            p.depth = depth;

            for(int i = -1; i <= 1; i++)
            {
                for(int j = -1; j <= 1; j++)
                {
                    p.x = x + j;
                    p.y = y + i;

                    if (!IsValid(p.x, p.y)) continue;

                    map[p.depth, p.y, p.x] = true;
                }
            }
        }

        public bool Solve(Position pos)
        {
            Stack<Position> stk = new Stack<Position>();
            stk.Push(pos);

            bool isArrival = false;

            while (stk.Count > 0)
            {
                Position cur = stk.Pop();

                if (cur.depth == n - 1)
                {
                    isArrival = true;
                    break;
                }

                for (int i = 0; i < 12; i++)
                {
                    Position next;
                    next.x = cur.x + moveX[i];
                    next.y = cur.y + moveY[i];
                    next.depth = cur.depth + 1;
                    
                    if (IsValid(next.x, next.y) && map[next.depth, next.y, next.x])
                    {
                        stk.Push(next);
                    }
                }
            }
            return isArrival;
        }

        private bool IsValid(int x,int y)
        {
            if (x < 0) return false;
            if (x > 9) return false;
            if (y < 0) return false;
            if (y > 9) return false;
            return true;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();
            
            while (true)
            {
                int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

                if (input.All(a => a == 0)) break;
                
                Position pos;
                pos.x = input[0];
                pos.y = input[1];
                pos.depth = -1;

                int n = int.Parse(Console.ReadLine());

                Puzzle pz = new Puzzle(n);

                input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                
                for(int i = 0; i < n; i++)
                {
                    int idx = i * 2;

                    pz.MakeMap(i, input[idx], input[idx + 1]);
                }

                sb.AppendLine(pz.Solve(pos) ? "OK" : "NA");
            }
            Console.Write(sb);
        }
    }
}

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

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

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

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

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

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

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

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

int main(){
    int n;
    cin >> n;
    vs a(n-1);
    rep(i, n-1) cin >> a[i];
    vector<vector<bool>> win(n, vector<bool>(n));
    rep1(i, n-1) rep(j, i) {
        win[i][j] = (a[i-1][j] == '1');
        win[j][i] = !(a[i-1][j] == '1');
    }
    vector<bitset<2005>> dpfl(n), dpfr(n), dpbl(n), dpbr(n);
    rep(i, n) dpfl[i][i] = dpfr[i][i] = dpbl[i][i] = dpbr[i][i] = true;
    rep1(i, n-1) rep(a, n-i) {
        int b = a + i;
        bool lok = false;
        auto &nfl = dpfl[b], &nbl = dpbl[a], &nfr = dpfr[b], &nbr = dpbr[a];
        if ((((nfl&nbl)>>(a+1))^((nfl&nbl)>>(a+i)<<(i-1))).any()) lok = true;
        if (!lok && win[a][b]) {
            if (((((nfr>>1)&nbl)>>a)^(((nfr>>1)&nbl)>>(a+i)<<i)).any()) lok = true;
        }
        nfl[a] = nbl[b] = lok;
        bool rok = false;
        if ((((nfr&nbr)>>(b-i+1))^((nfr&nbr)>>b<<(i-1))).any()) rok = true;
        if (!rok && win[b][a]) {
            if (((((nfr>>1)&nbl)>>(b-i))^(((nfr>>1)&nbl)>>b<<i)).any()) rok = true;
        }
        nfr[a] = nbr[b] = rok;
    }
    int ans = 0;
    rep(i, n) if (dpbr[0][i] && dpfl[n-1][i]) ++ans;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8824
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define MP make_pair
#define pb push_back
const int INF = 1e9;
const int MOD = INF+7;
using P = pair<int,int>;

signed main(){
    int N,M;
    cin >> N >> M;
    vector<int> B(N+1,1);
    vector<bool> P(N+1,false);
    B[0] = -1;
    P[1] = true;

    rep(i,M){
        int x,y;
        cin >> x >> y;
        P[y] = P[y] | P[x];
        B[x]--;
        B[y]++;
        if(B[x] == 0) P[x] = false;
    }

    int ans = 0;
    rep(i,N) ans += P[i+1];

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using namespace std;

const int LIM = 1300000;

char isprime[LIM];

int prime[LIM];
int lim = 0;

void eratosthenes() {
    fill(isprime, isprime + LIM, true);
    isprime[0] = isprime[1] = false;
    for(int x = 2; x < LIM; ++x) {
        if(isprime[x]) {
            prime[lim++] = x;
            if(x > sqrt(LIM)) continue;
            for(int y = x * x; y < LIM; y += x) {
                isprime[y] = false;
            }
        }
    }
}

int main(){
    eratosthenes();
    int N;
    while(true) {
        scanf("%d", &N);
        if(N == 0) break;
        int res = 0;
        if(!isprime[N] && N > 2) {
            int* left = lower_bound(prime, prime + lim, N) - 1;
            int* right = upper_bound(prime, prime + lim, N);
            res = *right - *left;
        }
        printf("%d\n", res);
    }
    return 0;
}

Measured memory_bytes: 3836
n, a, b  = map(int, input().split())

for _ in range(n):
    if a < b:
        a += 1
        if a == b:
            print('Borys')
            exit()

    if b <= n:
        b += 1
    else:
        b -= 1
        if b == a:
            print('Alice')
            exit()
else:
    print('Draw')


Measured memory_bytes: 9040
#include<iostream>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include<algorithm>
#include<algorithm>
#define L long long
#include<string.h>
#include <math.h>
long long  array1[100002];
using namespace std;
int n;
long long a,b;
int judge(int x)
{
    long long sum=0;
      for(int i=0;i<n;i++)
      {
          long long num=array1[i]-x*b;
          if(num>0)
          {
              sum+= ceil((num*1.0)/(a-b));
              if(sum>x||sum<0)
                return 0;
          }
      }
      return 1;
}

int main()
{   int i;
    while(cin>>n>>a>>b)
    {
        for(i=0;i<n;i++)
        {
        cin>>array1[i];
        }
            sort(array1,array1+n);
        long long l=0,r=array1[n-1];
         while(l<r)
         {
             long long mind=(l+r)>>1;
             if(judge(mind)==1)  r=mind;
             else
                 l=mind+1;
         }
         cout<<r<<endl;
    }

       return 0;
}


Measured memory_bytes: 1024
class WeightedUnionFind:
    def __init__(self, node:int) -> None:
        self.n = node
        self.par = [i for i in range(self.n)]
        self.rank = [0 for i in range(self.n)]
        self.diff_weight = [0 for i in range(self.n)]
        
    # ノードxのルートを求める
    def find(self, x:int) -> int:
        if x == self.par[x]:
            return x
        else:
            r = self.find(self.par[x])
            self.diff_weight[x] += self.diff_weight[self.par[x]]
            self.par[x] = r
            return self.par[x]
        
    # ノードxのルートからの距離を求める
    def weight(self, x:int) -> int:
        self.find(x)
        return self.diff_weight[x]
        
    # weight(y) - weight(x) = w となるようにする
    def unite(self, x:int, y:int, w:int) -> bool:
        if self.isSame(x,y):
            #print("x and y has already united")
            return False
        
        w += self.weight(x)
        w -= self.weight(y)
        
        rx = self.find(x)
        ry = self.find(y)
        
        if self.rank[rx] < self.rank[ry]:
            rx, ry = ry, rx
            w = -w

        self.par[ry] = self.par[rx]
        self.diff_weight[ry] = w
        
        if self.rank[rx] == self.rank[ry]:
            self.rank[rx] += 1
                
        return True
                
    
    def isSame(self, x:int, y:int) -> bool:
        return self.find(x) == self.find(y)
    
    def diff(self, x:int, y:int) -> int:
        if self.isSame(x,y):
            return self.weight(y)-self.weight(x)
        else:
            raise ValueError("xとyは同じ木に属していません")


  
N,M = map(int, input().split())
query = []
for _ in range(M):
    query.append(tuple(map(int, input().split())))
    
uf = WeightedUnionFind(N)
    
consistent = True
for l,r,d in query:
    l -= 1
    r -= 1
    if uf.isSame(l,r):
        if d != uf.diff(l,r):
            consistent = False
            break
    else:
        uf.unite(l,r,d)
        
if consistent:
    print("Yes")
else:
    print("No")
    

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli a,b;
vll t;

void error(){
  cout << "NO" << endl;
  exit(0);
}

int main(){
  t = vll(4, 0ll);
  for(lli i = 0;i < 3;i++){
    cin >> a >> b;
    t[a-1]++;
    t[b-1]++;
  }
  for(lli i = 0;i < 4;i++){
    if(t[i] == 3) error();

  }
  cout << "YES" << endl;
  return 0;

}


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

typedef long long lint;
typedef long double ldouble;
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = 1e18;
const lint MOD = 1e9 + 7;
const lint inv = MOD - 2;

int main(){
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
    }
    SORT(a);
    int ans = 0;
    rep(i, n-1){
        if(x >= a[i]){
            x -= a[i];
            ans++;
        }
    }
    if(x == a[n-1]){
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int minv=99999999;
	minv=min(a+b,minv);
	minv=min(c+b,minv);
	minv=min(c+a,minv);
	cout<<minv;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;


int main() {

    int A, B, K;
    cin >> A >> B >> K;

    for (int i = 0; i < K; ++i) {
        if(A % 2 != 0){
            A--;
        }
        B +=  A / 2;
        A = A / 2;

        i++;
        if(i >= K){
            break;
        }
        if(B % 2 != 0){
            B--;
        }
        A +=  B / 2;
        B = B / 2;
    }

    cout << A << " " << B << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll A, B, N;
    cin >> A >> B >> N;
    cout << (A * min(N,B-1) / B) << endl;
}

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

using namespace std;

int main() {
  int N, A, B;
  cin >> N >> A >> B;

  int answer = 0;
  for (int i = 1; i <= N; i++) {
    int sum = 0;
    int target = i;
    while (target > 0) {
      sum += target % 10;
      target /= 10;
    }

    if (sum >= A && sum <= B) {
      answer += i;
    }
  }

  cout << answer << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

const int N=2*1e3+5,Mo=1e9+7;

int n,k,ans,f[N][N];

int main() {
	scanf("%d%d",&n,&k);
	f[0][n+1]=1;
	fo(i,1,k-1) {
		fd(j,n,1) (f[i-1][j]+=f[i-1][j+1])%=Mo;
		fo(j,1,n-i+1) f[i][j]=f[i-1][j];
	}
	fo(i,2,n+1) (ans+=f[k-1][i])%=Mo;
	fo(i,1,n-k-1) ans=(ans*2)%Mo;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 15872