akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int N, M;
        cin >> N >> M;

        int num[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

        vector<int> A(M);
        rep(i, 0, M) cin >> A[i];

        vector<int> dp(N + 1, -1);
        dp[0] = 0;
        vector<int> prev(N + 1, -1);
        vector<int> vals(N + 1, -1);
        for (int i = 0; i < N; ++i) {
            if (dp[i] == -1) continue;
            for (auto e : A) {
                int f = num[e];
                if (i + f <= N) {
                    if (dp[i + f] < dp[i] + 1) {
                        dp[i + f] = dp[i] + 1;
                        prev[i + f] = i;
                        vals[i + f] = e;
                    } else if (dp[i + f] == dp[i] + 1 && vals[i + f] < e) {
                        prev[i + f] = i;
                        vals[i + f] = e;
                    }
                }
            }
        }

        vector<int> digits;
        int tapi = N;
        while (tapi > 0) {
            int next = prev[tapi];
            digits.push_back(tapi - next);
            tapi = next;
        }

        string ans;
        for (auto e : digits) {
            int val = -1;
            for (auto a : A) {
                if (num[a] == e && a > val) {
                    val = a;
                }
            }
            if (val == -1) {
                exit(-1);
            }
            ans += char(val + '0');
        }

        sort(ans.rbegin(), ans.rend());
        cout << ans << endl;

    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i > 0; i--)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
template <typename Iter> std::string join(Iter begin, Iter end, std::string const& separator){ std::ostringstream result; if (begin != end){ result << *begin++; }; while (begin != end){ result << separator << *begin++; }; return result.str(); }
using namespace std;
typedef long long ll;
void solve() {
  ll N; cin >> N;
  cout << N * N * N << endl;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


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

#define pb push_back
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000

using namespace std;

typedef long long ll;   
typedef double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<int> vi;

int main(){

    ld r;
    cin>>r;

    ld ans = 2*M_PI*r;

    cout<<ans<<endl;

    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}


Measured memory_bytes: 3736
import sys
X, N = map(int, input().split())
if (N==0):
    print(X)
    sys.exit()
p = list(map(int, input().split()))

n_ans = 0
sa = 200
for k in range(0,102,1):
    if (k in p):
        continue
    if(abs(k-X) < sa):
        n_ans = k
        sa = abs(k-X)
    else:
        break
print(n_ans)

Measured memory_bytes: 9200
#include<stdio.h>
#include<string.h>
int main() {
   char str[100], temp;
   int i, j = 0;
   while (gets(str)){
   i = 0;
   j = strlen(str)-1;
   while (i<j) {
      temp = str[i];
      str[i] = str[j];
      str[j] = temp;
      i++;
      j--;
   };

   printf("%s\n",str);
   };
   return (0);
}

Measured memory_bytes: 524
#include <stdio.h>
using namespace std;

int main(){
//  FILE*fin=fopen("a.in", "r");
  FILE*fin=stdin;
  int a, b, c;
  fscanf(fin, "%d%d%d ", &a, &b, &c);
  if(a==b)
    printf("%d", c);
  else
    if(b==c)
      printf("%d", a);
    else
      printf("%d", b);

  return 0;
}


Measured memory_bytes: 128
from random import randint

D = int(input())
cl = list(map(int, input().split()))
sl = [list(map(int, input().split())) for _ in range(D)]

def score(d, ti, last):
    s = sl[d-1][ti]
    for i in range(len(cl)):
        c = cl[i]
        s -= c*(d-last[i])
    return s

def scores(tl):
    s = 0
    last = [0]*26
    for d in range(D):
        t = tl[d] - 1
        last[t] = d+1
        s += score(d+1,t,last)
    return s


tl = [randint(1,26) for _ in range(D)]
s = scores(tl)
for _ in range(10000):
    d = randint(1,D)
    q = randint(1,26)
    x = tl[d-1]
    tl[d-1] = q
    s2 = scores(tl)
    if s2>s:
        s = s2
    else:
        tl[d-1] = x


for t in tl:
    print(t)



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

int main(){
    int N;
    cin>>N;
    vector<int> A(200);

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

    int ans=0;

    while(true){
        bool exist_odd=false;
        for(int i=0;i<N;i++){
            if(A[i]%2==1){
                exist_odd=true;
            }
        }

        if(exist_odd){
            break;
        }
        
        for(int i=0;i<N;i++){
            A[i] /= 2;
        }

        ans++;
    }

    cout << ans <<endl;
}


Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).ok();
	s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().split_whitespace()
		.map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
	(0..n).map(|_| read_vec()).collect()
}

pub trait LexicalPermutation {
	/// Return `true` if the slice was permuted, `false` if it is already
	/// at the last ordered permutation.
	fn next_permutation(&mut self) -> bool;
}
impl<T> LexicalPermutation for [T] where T: Ord {
	/// Original author in Rust: Thomas Backman <serenity@exscape.org>
	fn next_permutation(&mut self) -> bool {
		// These cases only have 1 permutation each, so we can't do anything.
		if self.len() < 2 { return false; }

		// Step 1: Identify the longest, rightmost weakly decreasing part of the vector
		let mut i = self.len() - 1;
		while i > 0 && self[i-1] >= self[i] {
			i -= 1;
		}

		// If that is the entire vector, this is the last-ordered permutation.
		if i == 0 {
			return false;
		}

		// Step 2: Find the rightmost element larger than the pivot (i-1)
		let mut j = self.len() - 1;
		while j >= i && self[j] <= self[i-1]  {
			j -= 1;
		}

		// Step 3: Swap that element with the pivot
		self.swap(j, i-1);

		// Step 4: Reverse the (previously) weakly decreasing part
		self[i..].reverse();

		true
	}
}

fn main() {
	let k: usize = read();
	let series = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51];
	println!("{}", series[k-1]);
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a=0,b=0,c=0,d,n=0,x=0;
    VI m(3);
    string s,s1,s2;
    cin >> a >> b; 
    if(a%2==0 || b%2==0) cout << "No" << endl;
    else cout << "Yes" <<endl;
    return 0;
} 

Measured memory_bytes: 256
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
int n,a[4][100111];
int A[100111],B[100111];
int tab[100111];
void add(int x){for(int i=x;i<=100005;i+=i&(-i))tab[i]++;}
int query(int x){int ret=0;for(int i=x;i;i-=i&(-i))ret+=tab[i];return ret;}
bool geta(int a[],int n)
{
	memset(tab,0,sizeof(tab));
	for(int i=1;i<=n;i++)assert(a[i]>=1&&a[i]<=n);
	int ret=0;
	for(int i=n;i>=1;i--)ret+=query(a[i]),add(a[i]);
//	for(int i=1;i<=n;i++)cerr<<a[i]<<" ";cerr<<endl;
//	cerr<<"ret="<<ret<<endl;	
	return ret&1;
}
int main()
{
	geti(n);
	for(int i=1;i<=n;i++)geti(a[1][i]);
	for(int i=1;i<=n;i++)geti(a[2][i]);
	for(int i=1;i<=n;i++)geti(a[3][i]);
	for(int j=1;j<=n;j++)
	{
		if(abs(a[1][j]-a[2][j])!=1||abs(a[2][j]-a[3][j])!=1||abs(a[1][j]-a[3][j])!=2)
		{
			puts("No");
			return 0;
		}
	}
	int cnt0=0,cnt1=0;
	for(int i=1;i<=n;i++)
	{
		if(i%2==0)
		{
			if(((a[1][i]+2)/3)%2!=0)
			{
				puts("No");
				return 0;
			}
			B[i/2]=(a[1][i]+2)/6;
			if(a[1][i]%3==0)cnt0^=1;
		}
		else
		{
			if(((a[1][i]+2)/3)%2!=1)
			{
				puts("No");
				return 0;
			}
			A[(i+1)/2]=(a[1][i]+5)/6;
			if(a[1][i]%3==0)cnt1^=1;
		}
	}
//	cerr<<cnt0<<" "<<cnt1<<endl;
	bool sa=geta(A,(n+1)/2);
	bool sb=geta(B,n/2);
	if(sa==cnt0&&sb==cnt1)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    string s,t;
    cin >> s >> t;
    int n=s.size();
    int ctr=0;

    rp(i,n){
        if(s[i]!=t[i]) ctr++;
    }
    print(ctr);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

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

int lc(const void *a,const void *b){
    if(*(long*)a == *(long*)b)return 0;
    return *(long*)a < *(long*)b?1:-1;
}

int main(void){
    int x,y,a,b,c,i;
    scanf("%d %d %d %d %d",&x,&y,&a,&b,&c);
    long p[a],q[b],r[c];
    for(i = 0;i < a;i++)scanf("%ld",&p[i]);
    for(i = 0;i < b;i++)scanf("%ld",&q[i]);
    for(i = 0;i < c;i++)scanf("%ld",&r[i]);
    qsort(p,a,sizeof(long),lc);
    qsort(q,b,sizeof(long),lc);
    qsort(r,c,sizeof(long),lc);
    long m[x+y+c];
    for(i = 0;i < x;i++)m[i] = p[i];
    for(i = 0;i < y;i++)m[i+x] = q[i];
    for(i = 0;i < c;i++)m[i+x+y] = r[i];
    qsort(m,x+y+c,sizeof(long),lc);
    long long ans = 0;
    for(int i = 0;i < x+y;i++)ans += m[i];
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 7660
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(int i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;

int main(void){
  double t, x;
  cin >> t >> x;
  printf("%.10f\n", t/x);
  return 0;
}

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

using namespace std;

int N, M;
int edge[55][55];
int ans[55];

void solve() {
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			ans[i] += edge[i][j];
		}
	}
	for (int i = 0; i < N; i++) {
		cout << ans[i] << endl;
	}
}

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		edge[a][b] += 1;
		edge[b][a] += 1;
	}
	solve();
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
#include<unordered_map>
#include<string>
#include<utility>
using namespace std;
int main() {
	vector<pair<string, int>> p;
	string str;
	vector<int>num(10000);
	int n,pos=0;
	while (cin >> str) {
		cin >> n;
		p.push_back(pair<string, int>(str, n));
	}
	sort(p.begin(),p.end());
	auto itr = p.begin();
	cout << itr->first << endl << itr->second;
	itr++;
	while (itr!=p.end()) {
		if ( (itr - 1)->first == itr->first) {
			cout << " " << itr->second ;
		}
		else {
			cout <<endl<< itr->first << endl<<itr->second;
		}
		itr++;
	}cout << endl;
	return 0;
}


Measured memory_bytes: 3288
"use strict";

const main = arg => {
    const input = arg.trim().split("\n");

    const a = parseInt(input[0].split(" ")[0]);
    const b = parseInt(input[0].split(" ")[1]);
    const n = parseInt(input[0].split(" ")[2]);
    const x = Math.min(b-1, n)
    const helper = function(x){
        return Math.trunc(a*x/b) - a*Math.trunc(x/b)
    }
    console.log(helper(x))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));  

Measured memory_bytes: 29620
/*
    AUTHOR:hruday pabbisetty
    NIT ROURKElA
*/
#include <bits/stdc++.h>
using namespace std;
#define opt ios_base::sync_with_stdio(0)
#define lli long long int
#define ulli unsigned long long int
#define I int
#define S string
#define D double
#define rep(i,a,b) for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define in(n) scanf("%lld",&n)
#define in2(a,b) scanf("%lld %lld",&a,&b)
#define in3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define out(n) printf("%lld\n",n)
#define inu(a) scanf("%lld",&a)
#define outu(a) printf("%llu",a)
#define ins(s) scanf("%s",&s)
#define outs(s) printf("%s",s)
#define nl printf("\n")
#define mod 1000000007
#define inf 100000000000000
typedef long long       ll;
typedef pair<lli,lli>  plli;
typedef vector<lli>     vlli;
typedef vector<ulli>    vulli;
typedef vector<ll>      vll;
typedef vector<string>  vs;
typedef vector<plli>     vplli;
#define MM(a,x)  memset(a,x,sizeof(a));
#define ALL(x)   (x).begin(), (x).end()
#define P(x)       cerr<<"{"#x<<" = "<<(x)<<"}"<<endl;
#define P2(x,y)       cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<"}"<<endl;
#define P3(x,y,z)  cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<"}"<<endl;
#define P4(x,y,z,w)cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<", "#w" = "<<(w)<<"}"<<endl;
#define PP(x,i)     cerr<<"{"#x"["<<i<<"] = "<<x[i]<<"}"<<endl;
#define TM(a,b)     cerr<<"{"#a" -> "#b": "<<1000*(b-a)/CLOCKS_PER_SEC<<"ms}\n";
#define UN(v)    sort(ALL(v)), v.resize(unique(ALL(v))-v.begin())
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define sz() size()
//#define nl cout<<"\n"
#define MX1 100005
#define MX2 1000005
#define sqr(a) a*a*a
#define bs binary_search
#define lb lower_bound
#define ub upper_bound

lli power(lli a,lli b)
    {
    lli value;
    if(b==0)
        {
        return 1;
    }
    else if(b%2==0)
        {
        value=power(a,b/2)%mod;
        return(value*value)%mod;
    }
    else
        {
        value=power(a,b/2)%mod;
        return ((a*value)%mod*(value))%mod;
    }
}
int main()
{
      /*  #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        #endif*/
    opt;
    lli x,a,b;
    cin>>x>>a>>b;
    if(abs(x-a)<=abs(x-b))
    {
        cout<<"A";
    }
    else
    {
        cout<<"B";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int solve(){
    string s;
    cin>>s;
    if(s[0]==s[1] && s[1]==s[2] && s[2]=='R')
        return 3;
    if(s[0]==s[1] && s[1]=='R' || s[1]==s[2] && s[2]=='R')
        return 2;
    if(s[0]=='R' || s[1]=='R' || s[2]=='R')
        return 1;
    return 0;
}
int main() {
    cout<<solve();
}


Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.math.BigDecimal;

public class Main {
  static InputReader in;
  static PrintWriter out;

  static class Solution {
    void solve() throws IOException {
      int x = in.nextInt();
      int y = in.nextInt();
      
      int gcd = gcd(x ,y);
      out.println(gcd);
//      End solve()
    }
    
    int gcd(int x, int y) {
      if (x < y) {
        int tmp = x;
        x = y;
        y= tmp;
      }
      while (y > 0) {
        int r = x % y;
        x = y;
        y = r;    
      }
      
      return x;
    }
    
//    End Solution
}


  public static void main(String[] args) throws IOException {
    in = new InputReader(System.in);
    out = new PrintWriter(System.out);
    Solution solver = new Solution();
    solver.solve();
    out.close();
}


  static class InputReader {
    public BufferedReader br;
    public StringTokenizer st;

    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream));
    }

    public int nextInt() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Integer.parseInt(st.nextToken());
    }

    public long nextLong() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Long.parseLong(st.nextToken());
    }

    public String next() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return st.nextToken();
    }

    public double nextDouble() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Double.parseDouble(st.nextToken());
    }

  }

}

Measured memory_bytes: 24292
using System;
using System.Linq;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] XY = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            string answer;
            bool b = false;
            for (int i = 0;i <= XY[0];i++)
            {
                if(i * 2 + (XY[0] - i) * 4 == XY[1])
                {
                    b = true;
                    break;
                }
            }
            if(b)
            {
                answer = "Yes";
            }else{
                answer = "No";
            }
            Console.WriteLine(answer);
        }
    }
}


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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60; const ll MOD = 1000000007;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

//---------------------------------------------------------------------------------------------------
void _main() {
    ll N, M; cin >> N >> M;
    vector<ll> coin(M);

    rep(i, 0, M) {
        cin >> coin[i];
    }
    vector<ll> minimum(N+1);
    minimum[0] = 0;
    rep(i, 1, N+1) {
        ll min = N + 1;
        rep(j, 0, M) {
            if(coin[j] <= i) {
                // cout << i << " " << coin[j] << " " <<  minimum[i-coin[j]] << endl;
                ll tmp = 1 + minimum[i-coin[j]];
                // cout << "tmp: " << tmp << " " << i << endl;
                chmin(min, tmp);
            }
        }
        minimum[i] = min;
    }
    cout << minimum[N] << endl;
}


Measured memory_bytes: 3352
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            String[] array = reader.readLine().split(" ");
            int A = Integer.parseInt(array[0]);
            int B = Integer.parseInt(array[1]);

            if ((A + B) % 2 == 1) {
                System.out.println("IMPOSSIBLE");
            } else {
                System.out.println((A + B) / 2);
            }
        }
    }

}


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

#define rep_0(i, end) for(int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for(int i = (fr); i <= (ba); ++i)
#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define overload_rep(arg_0, arg_1, arg_2, name, ...) name
#define all(box) box.begin(), box.end()

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

int main() {

    int a, b, c;
    cin >> a >> b >> c;
    cout << (a + b + c >= 22 ? "bust\n" : "win\n");

}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
MOD = 10**9+7
n = int(input())
edges = [[] for _ in range(n)]
for _ in range(n-1):
	x, y = map(int, input().split())
	edges[x-1].append(y-1)
	edges[y-1].append(x-1)

dp = [[1 for _ in range(2)] for _ in range(n)]
#0が白, 1が黒

def dfs(cur, par):
	for e in edges[cur]:
		if e == par:
			continue
		dfs(e, cur)
		dp[cur][0] = (dp[cur][0] * (dp[e][0]+dp[e][1])) % MOD
		dp[cur][1] = (dp[cur][1] * dp[e][0]) % MOD

	return

dfs(0, -1)
print((dp[0][0]+dp[0][1])%MOD)

Measured memory_bytes: 111664
#require 'prime'
#require 'openssl'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+).to_i end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../../abc/nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n=gi
a=gsmi
a.each_slice(2) do |ar|
  tar=ar[0]
  cnt+=1 if tar.odd?
end
puts cnt

Measured memory_bytes: 14324
N, M = map(int,input().split())
t = [[] for _ in range(N)]
visited = [0] * N
for _ in range(M):
    X, Y, Z = map(int,input().split())
    X -= 1
    Y -= 1
    t[X].append(Y)
    t[Y].append(X)
ans = 0
for i in range(N):
    if visited[i]:
        continue
    ans += 1
    stack = [i]
    while stack:
        s = stack.pop()
        for to in t[s]:
            if visited[to]:
                continue
            visited[to] = 1
            stack.append(to)
print(ans)

Measured memory_bytes: 23648
#Satoooh blog 友達もブロックdiも、まとめて配列direct[i]にappend
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parent = [i for i in range(n)]  # 親
        self.rank = [1] * n  # 木の高さ
        self.size = [1] * n  # size[i] は i を根とするグループのサイズ

    def find(self, x):  # x の根を返す
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])  # 経路圧縮
            return self.parent[x]

    def unite(self, x, y):  # x, y の属する集合を併合する
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1

    def is_same(self, x, y):  # x, y が同じ集合に属するか判定する
        return self.find(x) == self.find(y)

    def group_size(self, x):  # x が属する集合の大きさを返す
        return self.size[self.find(x)]


N, M, K = map(int, input().split())
A, B = [0] * M, [0] * M  # 入力時に 0-index に合わせる
C, D = [0] * K, [0] * K  # 入力時に 0-index に合わせる

direct =[[] for _ in range(N)]  # 同じ集合の友達もしくはブロック関係の人
uf = UnionFind(N)  # 友達関係をまとめた UnionFind 木

for i in range(M):
    A[i], B[i] = map(int, input().split())
    A[i] -= 1
    B[i] -= 1
    direct[A[i]].append(B[i])
    direct[B[i]].append(A[i])
    uf.unite(A[i], B[i])

for i in range(K):
    C[i], D[i] = map(int, input().split())
    C[i] -= 1
    D[i] -= 1
    if uf.is_same(C[i], D[i]):
        direct[C[i]].append(D[i])
        direct[D[i]].append(C[i])

ans = [0] * N
for i in range(N):
    ans[i] = uf.group_size(i) - len(direct[i]) - 1
print(*ans)

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

int N, M;
vector<int> A(110, 0);
double sum = 0;

int main(){
  cin >> N >> M;

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

  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  sum /= (4 * M);

  int i = 0;
  while(A[i] >= sum) ++i;

  if(i >= M) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}
  



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

int main() {
  int n, m;
  cin >> n >> m;
  if(n < 2 && m < 2) {cout << 0 << endl; return 0;}
  int sum = 0;
  if(!(n < 2)) sum += n * (n-1) / 2;
  if(!(m < 2)) sum += m * (m-1) / 2;
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;
#define watch(x) cout << #x << " is " << x << endl;
#define print(a, l, r) \
    for (int i = l; i < r; i++) cout << a[i] << (i == (r - 1) ? endl : " ");
const long long M = 1000000007;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll k;
    cin >> k;
    ll a = 7;
    for (ll i = 1; i <= 1000000; i++) {
        if (a % k == 0) {
            cout << i << endl;
            return 0;
        }
        a = (a * 10 + 7) % k;
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A, B;
  cin >> A >> B;
  double e = A/0.08;
  double e_2 = (A+1)/0.08;
  double t = B/0.1;
  double t_2 = (B+1)/0.1;
  vector<int> vec(0);
  if(A%2 == 1){
    for(int i=floor(e)+1; i<floor(e_2); i++){
        if((B <= 0.1*i)&&(0.1*i < B+1)){
            vec.push_back(i);
        }
    }
  }
  else{
    for(int i=floor(e); i<floor(e_2); i++){
        if((B <= 0.1*i)&&(0.1*i < B+1)){
            vec.push_back(i);
        }
    }
  }
  if(vec.size() == 0){
      cout << -1;
  }
  else{
      cout << vec[0];
  }
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
  i64 a;
  string s;

  cin >> a >> s;
  if (a >= 3200) {
    cout << s << endl;
  } else {
    cout << "red" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

char s[55], t[55];

int main()
{
	while(scanf("%s", s + 1) != EOF)
	{
		scanf("%s", t + 1);
		int ls = strlen(s + 1);
		int lt = strlen(t + 1);
		bool flag = 0;
		int pos = 0;
		for(int i = 1; i <= ls - lt + 1; i++) {
			bool ok = 1;
			for(int j = 1; j <= lt; j++) {
				if(s[j + i - 1] != t[j] && 
					s[j + i - 1] != '?')
					ok = 0;
			}
			if(ok == 1) {
				pos = i;
				flag = 1;
				//break;
			}
		}
		if(flag == 0) printf("UNRESTORABLE\n");
		else {
			for(int i = 1; i < pos; i++) {
				if(s[i] == '?') printf("a");
				else printf("%c", s[i]);
			}
			for(int i = 1; i <= lt; i++)
				printf("%c", t[i]);
			for(int i = pos + lt; i <= ls; i++) {
				if(s[i] == '?') printf("a");
				else printf("%c", s[i]);
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 128
# ABC083 B - Some Sums
# 2019/11/07

N,A,B = map(int, open(0).read().split())
# print(N, A, B)
ans = 0
for i in range(1, N+1):
    sum_digit = sum([int(i) for i in list(str(i))])
    if A <= sum_digit <= B:
        ans += i
print(ans)

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

int main(void){
    int n,k;
    cin>>n>>k;
    vector<int> p(n),c(n);
    rep(i,n)cin>>p[i];
    rep(i,n)cin>>c[i];

    ll ans=-1e9-1;
    rep(i,n){
        ll mx=-1e9-1;
        ll sum=0;
        int position;
        int a=p[i]-1;
        sum+=c[a];
        mx=max(mx,sum);
        int times=1;
        while(a!=i && times<k){
            a=p[a]-1;
            sum+=c[a];
            times++;
            if(mx<sum){
                mx=sum;
            }
        }
        int loop=k/times;
        int left=k%times;
        if(sum<=0)ans=max(mx,ans);
        else{
            sum*=(loop-1);
            a=p[i]-1;
            rep(j,left+times){
                sum+=c[a];
                a=p[a]-1;
                mx=max(mx,sum);
            }
            ans=max(mx,ans);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3640
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  int a,b,c,d;
  scanf("%d %d %d %d\n",&a,&b,&c,&d);
  while(1){
    c=c-b;
    if(c<=0){
      break;
    }
    a=a-d;
    if(a<=0){
      break;
    }
  }
  if(c<=0){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 3764
//#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>
#include<time.h>



#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define ALL(x) x.begin(),x.end()
#define sz(a) ((int)a.size())
#define getmid ((l+r)>>1)
#define mst(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define lowbit(x) x&(-x)
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ls rt<<1
#define rs rt<<1|1
using namespace std;
#ifdef local
#define dbg(args...) cout << #args << " -> ", err(args);
void err(){ cout << endl; }
template<typename T, typename... Args>
void err(T a, Args... args){ cout << a << ' '; err(args...); }
#else
#define dbg(args...)
#endif // local

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <double, double> pdd;
const int inf=0x3f3f3f3f;
const long long INF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const long double eps=1e-8;
const int mod=998244353;
const int maxn=1e6+100;
const int N=2e5+100;
const int M=2e6+10;
const ll mm=(1LL<<32);

template <class T>
inline void read(T &x)
{
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar())
        f ^= c == '-';
    for (; isdigit(c); c = getchar())
        x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10)
        ++len;
    for (; len; --len, x %= y, y /= 10)
        putchar(x / y + 48);
}
ll qpow(ll a,ll b,ll mod)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b>>=1;
        a=(a*a)%mod;
    }
    return ans;
}

ll a[N],b[N];
int main()
{
#ifdef local
      freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif // local
    IOS;cout.tie(0);
    int n,m;ll k;cin>>n>>m>>k;
    rep1(i,n) cin>>a[i],a[i]+=a[i-1];
    rep1(i,m) cin>>b[i],b[i]+=b[i-1];
    int ans=0;
    for(int i=0,j=m;i<=n;++i)
    {
        while(j>0&&a[i]+b[j]>k) j--;
        if(j==0&&a[i]>k) break;
        ans=max(i+j,ans);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6740
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
 
using namespace std;
 
#define int long long
#define endl "\n"
 
const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 
 
string yn(bool f){return f?"P":"C";}
string YN(bool f){return f?"YES":"NO";}
 
 
 
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
     
    int T;
    int p, q;
     
    cin>>T;
     
    for(int i = 0; i < T; i++){
        int ans = 0, x;
         
        cin>>p>>q;
         
        x = max(abs(p),abs(q));
        for(int m = 0; m <= x; m++){
            for(int n = 0; n <= x; n++){
                if(n+m == 0) continue;
                 
                if((q*q+p*p)%(n*n+m*m) == 0) ans += 2;
            }
        }
        cout<<yn(ans <= 8)<<endl;
    }
     
     
    return 0;
}


Measured memory_bytes: 3004
#include<cstdio>
#include<algorithm>
#include<vector>
#include<iostream>

using namespace std;

int main(){
    int len_array,num_query;
    int key;
    scanf("%d",&len_array);
    vector<int> int_array(len_array);
    for(int i = 0;i < len_array;i++){
        cin >> int_array[i];
    }
    
    scanf("%d",&num_query);
    for(int i = 0;i < num_query;i++){
        scanf("%d",&key);
        vector<int>::iterator itr = lower_bound(int_array.begin(),int_array.end(),key);
        cout << itr - int_array.begin() << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 3416
#include <stdio.h>
int main(void) {
int N,M,C,total,ans=0;
scanf("%d %d %d",&N,&M,&C);
int A[N][M],B[M];
for(int i=0;i<M;i++){scanf("%d",&B[i]);}
for(int i=0;i<N;i++){
total=0;
for (int j=0;j<M;j++){
scanf("%d",&A[i][j]);
total+=A[i][j]*B[j];
}
if(total+C>0){ans+=1;}
}
printf("%d",ans);
return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<stdio.h>
using namespace std;
typedef long long ll;
int input(){
  int x;
  cin>>x;
  return x;
}
int abs(int x){
  if(x>=0){
    return x;
  }else{
    return -x;
  }
}
int gcd(int x, int y){
	if(x<y){
    return gcd(y,x);
  }
  if(y==0){
    return x;
  }
  return gcd(y,x%y);
}
int moji(char in)
{
    int ans = (int)in-(int)'a'+1;
    if((in < 1) || (in > 26)){
        ans = 100;
    }
    return ans;
}







int main() {
  int N,K;
  cin>>N>>K;
  int sum=1;
  for(int i=0;i<N;i++){
    if(sum*2>=sum+K){
      sum+=K;

    }else{
      sum*=2;
    }
  }
  cout<<sum<<endl;






  




  
  
}

  

  




Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int N = 10010;
int n, q;
int a[N];

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

	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	scanf("%d", &q);
	int k, cnt = 0;
	while (q--)
	{
		scanf("%d", &k);
		a[n] = k;  //设置哨兵，可省去循环结束条件的比较。
		int i = 0;
		while (a[i] != k) ++i;
		if (i != n) cnt++;
		
	}
	printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 3240
#include<iostream>
using namespace std;
int main() {
	double A = 0;
	double T;
	int t = 0;
	int B;
	cin >> A>>B>>T;
	for (int i = 1; A * i <= T + 0.5; i++) {
		t += B;
	}
	cout << t;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    int n, a, b; cin >> n >> a >> b;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    ll c = 1LL*a - 1LL*b;
    int ok = 1e9;
    int ng = 0;
    while(ok - ng > 1){
        int mid = (ok + ng) / 2;
        ll cnt = 0;
        rep(i, n){
            ll goal = 1LL*h[i] - 1LL*b*mid;
            if(goal > 0) cnt += (goal + c - 1) / c;
        }
        if(cnt <= mid) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
}

Measured memory_bytes: 640
D = ((-1,0), (0,-1), (1,0), (0,1))
F, f = False, False
H, W = map(int, input().split())
S = [""] * H

for i in range(H):
  S[i] = input()
  
for i in range(H):
  for j in range(W):
    if S[i][j] != ".":
      f = True
      for d in D:
        if (0 <= d[0]+i < H) and (0 <= d[1]+j < W) :
          if S[d[0]+i][d[1]+j] == "#":
            f = False
            break
    if f:
      F = True
if F:
  print("No")
else:
  print("Yes")

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

int main(){
	int n,A;
	cin>>n;
	vector<int> a;
	for(int i=0;i<n;i++){
		cin>>A;
		a.push_back(A);
	}
	for(int i=0;i<n;i++){
		int v=a[i];
		int j;
		for(j=i-1;j>=0&&a[j]>v;j--) a[j+1]=a[j];
		a[j+1]=v;
		for(j=0;j<n;j++){
			if(j==n-1) cout<<a[j]<<endl;
			else cout<<a[j]<<" ";
		}
	}
	return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << __LINE__ << ' ' << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
template<class T> using pque = priority_queue<T, vector<T>, greater<T>>;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr int mod1e9 = 1000000007;
constexpr int mod998 = 998244353;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
constexpr ll ten(int n) { return n ? 10 * ten(n - 1) : 1; };
int dx[] = { 1,0,-1,0,1,1,-1,-1 }; int dy[] = { 0,1,0,-1,1,-1,1,-1 };
void fail() { cout << "-1\n"; exit(0); } void no() { cout << "No\n"; exit(0); }
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }
template<class T> istream &operator >> (istream &s, vector<T> &v) { for (auto &e : v) s >> e; return s; }
template<class T> ostream &operator << (ostream &s, const vector<T> &v) { for (auto &e : v) s << e << ' '; return s; }

struct fastio {
	fastio() {
		cin.tie(0); cout.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(20);
		cerr << fixed << setprecision(20);
	}
}fastio_;

#include <atcoder/all>
using namespace atcoder;

int main() {
	int n, k;
	cin >> n >> k;
	mcf_graph<int, ll> g(2 * n + 2);
	g.add_edge(2 * n, 2 * n + 1, n * k, inf);
	rep(i, n) {
		g.add_edge(2 * n, i, k, 0);
		g.add_edge(n + i, 2 * n + 1, k, 0);
	}
	rep(i, n) {
		rep(j, n) {
			ll a;
			cin >> a;
			g.add_edge(i, n + j, 1, inf - a);
		}
	}
	auto res = g.flow(2 * n, 2 * n + 1, n * k);
	cout << n * k * (ll)inf - res.second << '\n';
	vector<vector<char>> ans(n, vector<char>(n, '.'));
	auto edge = g.edges();
	for (auto e : edge) {
		if (e.from != 2 * n && e.to != 2 * n + 1 && e.flow > 0) {
			ans[e.from][e.to - n] = 'X';
		}
	}
	rep(i, n) {
		rep(j, n) {
			cout << ans[i][j];
		}
		cout << '\n';
	}
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  int oddCnt = 0;
  int m = 1e9;
  ll s = 0;
  rep(i, n) {
    if (a[i] < 0) oddCnt++;
    s += abs(a[i]);
    m = min(m, abs(a[i]));
  }

  if (oddCnt % 2 == 0) {
    cout << s << endl;
  } else {
    cout << s - 2 * m << endl;
  }
  return 0;
}

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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	string s;
	cin >> s;
	int cnt = 0;
	char a[] = "CF";
	REP(i, 0, SZ(s))
	{
		if (s[i] == a[cnt]) ++cnt;
		if (cnt == 2) { puts("Yes"); return 0; }
	}
	puts("No");
	return 0;
}


Measured memory_bytes: 384
extension String: CollectionType {}
let num: [Int] = readLine()!.split(" ").map { Int($0)! }

var start = num[0]; var end = num[1]
if( num[0] > num[1] ){ 
  start = num[1]
  end = num[0]
}

var out = "No"
for i in start ... end {
  if( i == num[2] ) {
    out = "Yes"
    break
  }
}

print( out )


Measured memory_bytes: 768
#include <iostream>
#include <iomanip>
#include <string>
#include <unordered_map>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  ll n, k, h[200010] = {}, sum = 0;
  cin >> n >> k;
  for (ll i = 0; i < n; ++i) cin >> h[i];
  sort(h, h + n, greater<>());
  for (ll i = 0; i < n; ++i)
  {
    if (k > 0)
    {
      k--;
    }
    else
    {
      sum += h[i];
    }
  }

  cout << sum;
}


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

void    print(vector<int> P, int N)
{
    for (int i = 0; i < N; i++) cout << P[i];
}

int     main()
{
    int N; cin >> N;
    vector<int> P(N);
    vector<int> Q(N);
    int count = 0;
    for (int i = 0; i < N; i++) cin >> P[i];
    for (int i = 0; i < N; i++) cin >> Q[i];
    if (P == Q)  
    {   
        cout<<0<<endl;
        return 0;
    }   
    if (P > Q)
    {   
        swap(P, Q); 
    }   
    while (next_permutation(P.begin(), P.end()))
    {   
        count++;
        if (P == Q)
        {   
            cout << count << endl;
            return 0;
        }   
    }   
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <math.h>
using namespace std;

int main(void){
    int a, b;

    cin >> a >> b;
    int c = a + b;
    int d = a - b;
    int e = a * b;
    if(c >= d){
        if(c >= e){
            cout << c << endl;
        } else if(c < e){
            cout << e << endl;
        }
    } else if(c < d){
        if(d >= e){
            cout << d << endl;
        } else if(d < e){
            cout << e << endl;
        }        
    }
    
    return 0;
}

Measured memory_bytes: 256
<?php
    $a = fgets(STDIN);

    const INTS = [3,5,7];
    $results = check(null, $a, []);
    $unique = array_unique($results);

    echo count($unique);

    function check($a, $max, $acc) {
        $result = $acc;
        foreach(INTS as $int) {
            $next = (int) ($a . $int);
            if($next > $max) continue;
            if(strpos($next, '3') !== false && strpos($next,'5') !== false && strpos($next,'7') !== false
                && strlen($next)>2) $acc[] = $next;
            $ret = check($next, $max, $acc);
            $result = array_merge($result, $ret);
        }

        return $result;
    }


Measured memory_bytes: 32744
#include<bits/stdc++.h>
#define N 10001
#define M 501
using namespace std;
int main()
{
    int n,m;
    int a[N],b[M];
    cin>>n;
    for(int i=0;i<n;i++)
    cin>>a[i];
    cin>>m;
    for(int i=0;i<m;i++)
        cin>>b[i];
    int cnt=0;
    for(int i=0;i<m;i++)
        for(int j=0;j<n;j++)
        if(b[i]==a[j]) cnt++,j=n;
    cout<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 3112