akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
use std::io;
use std::io::Write;
use std::cmp::*;
use std::collections::*;
#[allow(dead_code)]
const M: i64 = 1e9 as i64 + 7;

fn read_line() -> String {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    buf
}
#[allow(dead_code)]
fn read<T>() -> T where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().trim().parse().unwrap()
}
#[allow(dead_code)]
fn readv<T>() -> Vec<T> where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().split(' ').map(|a| a.trim().parse().unwrap()).collect()
}

// fn solve(num: i64, hs: &Vec<i64>, a: i64, b: i64) -> bool {
//     let mut rem = num;
//     let damage = num * b;
//     for h in hs {
//         if h > &damage {
//             rem -= (h - damage + a - b - 1) / (a - b);
//         } else {
//             break;
//         }
//         if rem < 0 { return false; }
//     }
//     true
// }

fn main() {
    let input = readv();
    let (n, a, b) = (input[0], input[1], input[2]);
    let hs: Vec<i64> = (0..n).map(|_| { read() }).collect();
    let sol = |num| {
        let mut rem = num;
        let damage = num * b;
        for h in &hs {
            if h > &damage {
                rem -= (h - damage + a - b - 1) / (a - b);
            }
            if rem < 0 { return false; }
        }
        true
    };
    // #[cfg(local)] writeln!(&mut std::io::stderr(), "{:?}", hs).unwrap();
    #[cfg(local)] println!("{}: {:?}", "hs", hs);
    let (mut l, mut r) = (0, 1e9 as i64);
    while l < r {
        let piv = (l + r) / 2;
        if sol(piv) {
            r = piv;
        } else {
            l = piv + 1;
        }
    }
    println!("{}", l);
}


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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    ll x = 4*a*b;
    ll y = powl(c-a-b,2);
    if(y>x&&(c-a-b>0)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <algorithm>
using namespace std;
static const int MAX = 1405;

struct Rect { int pos, height; };
int G[MAX][MAX];
int H, W;

int getLargestRectangle(int buffer[])
{
    stack<Rect> S;
    int maxv = 0;
    buffer[W] = 0;

    for (int i = 0; i <= W; ++i)
    {
        Rect r;
        r.pos = i;
        r.height = buffer[i];
        if (S.empty())
        {
            S.push(r);
        }
        else
        {
            if (S.top().height < r.height)
            {
                S.push(r);
            }
            else if (S.top().height > r.height)
            {
                int target = i;
                while (!S.empty() && S.top().height >= r.height)
                {
                    Rect temp = S.top(); S.pop();
                    maxv = max(maxv, temp.height * (i - temp.pos));
                    target = temp.pos;
                }
                r.pos = target;
                S.push(r);
            }
        }
    }
    return maxv;
}

int main()
{
    cin >> H >> W;
    for (int i = 0; i != H; ++i)
    {
        for (int j = 0; j != W; ++j)
        {
            cin >> G[i][j];
            if (G[i][j])
            {
                G[i][j] = 0;
            }
            else
            {
                G[i][j] = (i > 0) ? G[i-1][j] + 1 : 1;
            }          
        }
    }

    int maxv = 0;
    for (int i = 0; i != H; ++i)
    {
        maxv = max(maxv, getLargestRectangle(G[i]));
    }
    cout << maxv << endl;
    return 0;
}


Measured memory_bytes: 10768
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int a, b;
    string op;
    while (1)
    {
        cin >> a >> op >> b;

        if (op == "*")
            cout << a * b;
        if (op == "/")
            cout << a / b;
        if (op == "+")
            cout << a + b;
        if (op == "-")
            cout << a - b;
        if (op == "?")
            break;

        cout << endl;
    }
}


Measured memory_bytes: 3148
#include<stdio.h>

int main(){
    char a,b,c;
    char n;

    scanf("%c%c%c%c%c",&a,&n,&b,&n,&c);

    if(a==b){
        if(a!=c)puts("Yes");
        else puts("No");
    }else if(a==c){
        if(a!=b)puts("Yes");
        else puts("No");
    }else if(b==c){
        if(a!=b)puts("Yes");
        else puts("No");
    }else{
        puts("No");
    }

    return 0;
}

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

using ll = long long;
using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(false)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YN(x)         cout << ((x) ? "YES" : "NO") << endl
#define Yn(x)         cout << ((x) ? "Yes" : "No") << endl
#define yn(x)         cout << ((x) ? "yes" : "no") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;

ll gcd(ll a, ll b) { return __gcd(a, b); }
ll lcm(ll a, ll b) { return (a == 0 || b == 0) ? 0 : (a / __gcd(a, b) * b); }

std::map<unsigned long long, unsigned long long> prime_factorization(unsigned long long n) {
	std::map<unsigned long long, unsigned long long> ret;
	if(n < 2) return ret;

	for(unsigned long long i = 2; i * i <= n; ++i) {
		while(n % i == 0) {
			ret[i] += 1;
			n /= i;
		}
	}

	if(n > 1) ret[n] = 1; 

	return ret;
}

int main(int argc, const char* argv[]) {
	ll a, b;
	cin >> a >> b;
	ll g = gcd(a, b);

	auto pf = prime_factorization(g);

	cout << pf.size() + 1 << endl;

	return 0;
}


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


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

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    ll n;
    cin>>n;
    ll ans=0;
    vector<ll> v(n);
    rep(i,n)
    {
      cin>>v[i];
      ans^=v[i];
    }
    rep(i,n)
    {
      ll val=ans^v[i];
      cout<<val<<" ";
    }
    cout<<'\n';
    return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!


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


def solve(W: int, H: int, x: int, y: int):
    r1 = W*H /2
    if W*y == H*x and W*y == -H*x+H*W:
        r2 = 1
    else:
        r2 = 0
    print(r1, r2)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    W = int(next(tokens))  # type: int
    H = int(next(tokens))  # type: int
    x = int(next(tokens))  # type: int
    y = int(next(tokens))  # type: int
    solve(W, H, x, y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>

void insertionSort(int* A, int N) {
    auto show_element =
        [&]() {
            for (int i = 0; i < N - 1; i++) {
                std::cout << A[i] << " ";
            }
            std::cout << A[N - 1] << std::endl;
        };
    
    show_element();
    
    for (int i = 1; i < N; i ++) {
        int val = A[i];
        int j = i - 1;

        while (j >= 0 && A[j] > val) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = val;
        show_element();
    }
}

int main(int argc, char ** argv) {
    int N;
    std::cin >> N;

    int arr[N];

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

    insertionSort(arr, N);
}



Measured memory_bytes: 3096
#include <stdio.h>
#include <string.h>
int main(void){
    char t[201],h[201];
    int n,taro=0,hanako=0;
        scanf("%d",&n);
    while(n--){
        scanf("%s %s",t,h);
        if(strcmp(t,h)>0)
            taro+=3;
        else if(strcmp(t,h)<0)
            hanako+=3;
        else{
            taro++;
            hanako++;
        }
    }
    printf("%d %d\n",taro,hanako);
    return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod=1e9+7;
 
int dx[]={-1, 0, 1, 0};
int dy[]={0, -1, 0, 1};

vector<int>d;
int dp[105][105][2];

int solve(int pos,int c,int check,int mx)
{
  if(pos==d.size())
  {
    if(c<=mx)return 1;
    return 0;
  }
  if(dp[pos][c][check]!=-1)return dp[pos][c][check];

  int r;
  if(check)r=9;
  else r=d[pos];

  int res=0;
  for(int i=0;i<=r;i++)
  {
    int x=c;
    if(i!=0)
    x++;
    int y=check;
    if(i<r)
    y=1;
    res+=solve(pos+1,x,y,mx);


  }
  return dp[pos][c][check]=res;
}


int call(string s,int x)
{
  d.clear();

  while(s.size())
  {
    int k=s.back()-'0';
    d.push_back(k);
    s.pop_back();
  }

  reverse(d.begin(),d.end());
  memset(dp,-1,sizeof(dp));
  return solve(0,0,0,x);
}



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

  
  string s;
  cin>>s; int k;
  cin>>k;

  int x=call(s,k);
  int y=call(s,k-1);
  cout<<x-y<<"\n";









}

Measured memory_bytes: 384
<?php
list($N, $K) = explode(" ", trim(fgets(STDIN)));
$vArray = explode(" ", trim(fgets(STDIN)));

$max = 0;
for($a = 0; $a <= min($N, $K); $a++){
    for($b = 0; $b <= min($N, $K) - $a; $b++){
        $sum = 0;
        $nega = [];
        for($i = 0; $i < $a; $i++){
            $sum += $vArray[$i];
            if($vArray[$i] < 0)$nega[] = $vArray[$i];
        }
        for($i = $N - $b; $i < $N; $i++){
            $sum += $vArray[$i];
            if($vArray[$i] < 0)$nega[] = $vArray[$i];
        }
        sort($nega);
        for($i = 0; $i < $K - $a - $b; $i++){
            @$sum-=$nega[$i];
        }
        $max = max($max, $sum);
    }
}
echo $max;

Measured memory_bytes: 4728
#include <bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000000
int MOD=1000000007;
int modpow(int a,int x){
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}
int gyaku(int n){
    return modpow(n,MOD-2);
}
signed main() {
  int x,y,a,b;
  cin>>a>>b;
  x=(2*b-a)/3;
  y=(2*a-b)/3;
  if((a+b)%3!=0||x<0||y<0){cout<<0<<endl;exit(0);}
  int ans=1;
  rep(i,x+y){
    ans=ans*(i+1)%MOD;
  }
  rep(i,x){
    ans=ans*gyaku(i+1)%MOD;
  }
  rep(i,y){
    ans=ans*gyaku(i+1)%MOD;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3604
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(){
	ll n,k;
	cin>>n>>k;
	vector<ll> v;
	rep(i,0,n){
		ll a;
		cin>>a;
		v.pb(a);
	}
	ll ans = 0;
	rep(i,0,v.sz){
		rep(j,i+1,v.sz){
			if(v[i]>v[j])ans += k*(k+1)/2;
			ans %= MOD;
			if(v[i]<v[j])ans += k*(k-1)/2;
			ans %= MOD;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main(int argc, char* argv[]) {
  int N, L;
  cin >> N >> L;
  
  vector<string> S(N);
  for (int i = 0; i < N; i++) {
    cin >> S[i];
  }

  sort(S.begin(), S.end());

  string ans = "";
  for (int i = 0; i < N; i++) {
    ans += S[i];
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i=(a);i>=(b);i--)
#define FORR(i,a,b) for (int i=(a);i>(b);i--)
typedef unsigned long long ull;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

    ll n,a,b,c,d,e;
    cin >> n >> a >> b >> c >> d >> e;

    cout << max({(n-1)/a,(n-1)/b,(n-1)/c,(n-1)/d,(n-1)/e})+5 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
string str;
int q;
int k[1000005];
ll sum[3][1000005];
vector<int> vec[3];

int main(void){
    scanf("%d",&n);
    cin >> str;
    for(int i=0;i<n;i++){
        if(str[i]=='D'){
            vec[0].push_back(i);
        }
        if(str[i]=='M'){
            vec[1].push_back(i);
        }
        if(str[i]=='C'){
            vec[2].push_back(i);
        }
    }
    for(int i=0;i<3;i++){
        for(int j=0;j<vec[i].size();j++){
            sum[i][vec[i][j]+1]++;
        }
        for(int j=0;j<n;j++){
            sum[i][j+1]+=sum[i][j];
        }
    }
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        scanf("%d",&k[i]);
        ll ans=0;
        ll su=0;
        int l=0,r=0;
        ll cnt=0;
        for(int j=0;j<vec[0].size();j++){
            while(r<vec[2].size() && vec[2][r]-vec[0][j]<k[i]){
                su+=sum[1][vec[2][r]];
                r++;
                cnt++;
            }
            while(l<vec[2].size() && vec[2][l]<vec[0][j]){
                su-=sum[1][vec[2][l]];
                l++;
                cnt--;
            }
            ans+=su-cnt*sum[1][vec[0][j]];
        }
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 30200
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	//java11

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();

		long[] A = new long[N];

		for(int i=0; i<N; i++) {
			A[i] = sc.nextLong();
		}

		PrintWriter pw = new PrintWriter(System.out);
		for(int i=K; i<N; i++) {
			if(A[i] > A[i-K]) {
				pw.println("Yes");
			}else {
				pw.println("No");
			}
		}
		pw.flush();

	}


}


Measured memory_bytes: 61176
#include <iostream>
#define int long long
using namespace std;

int f(int a, int b) {
	return a * a * a * a * a - b * b * b * b * b;
}

signed main() {
	int x;
	cin >> x;
	
	int b = -119;
	for (int a = -119; a <= 119; a++) {
		while (f(a, b) > x) {
			b++;
		}
		if (f(a, b) == x) {
			cout << a << " " << b << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3168
var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var H = Number(lines[0].split(" ")[0]);
    var W = Number(lines[0].split(" ")[1]);

    lines.shift();

    var a = lines.map(i => i.split(""));

    for (var i = 0; i < H; i++) {
        for (var j = 0; j < W; j++) {
            if (a[i][j] === "#") { break; }
            if (j === W - 1) { a.splice(i, 1); i--; H--; }
        }
    }

    for (var j = 0; j < W; j++) {
        for (var i = 0; i < H; i++) {
            if (a[i][j] === "#") { break; }
            if (i === H - 1) { for (var k = 0; k < H; k++) { a[k].splice(j, 1) }; j--; W--; }
        }
    }
    for (var i = 0; i < H; i++) {
        console.log(a[i].join(""));
    }
});



Measured memory_bytes: 7756
n, k = list(map(int, input().split()))
tele = list(map(int, input().split()))
loc = 1
act = [-1]*n
act[0]=0
count = 1
log = []
log.append(loc)
flg = True
while True:
  newloc=tele[loc-1]
  if count ==k:
    print(newloc)
    flg = False
  log.append(newloc)
  #print(newloc)
  if act[newloc-1] == -1:
    act[newloc-1] =count
  else:
    loop=count-act[newloc-1]
    loopstart=act[newloc-1]
    break
  count+=1
  loc=newloc

  

if flg:
  num = (k-loopstart) % loop 
  ans=log[loopstart+num]
  print(ans)

#print(loopstart)
#print(log)
#print(log[loopstart])
#print(num)
  

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

int main() {
	int number;
	char input;
	int e=0;
	int w=0;
	std::vector<int> vecW;
	std::vector<int> vecE;

	std::cin >> number;

	for (int i = 0; i < number; i++) {
		std::cin >> input;
		vecW.emplace_back(w);
		if (input == 'E')
			e += 1;
		else
			w += 1;
		vecE.emplace_back(e);
	}

	int answer = number - 1;

	for (int i = 0; i < number; i++)
		answer = std::min(answer, vecW[i] + (e - vecE[i]));

	std::cout << answer << std::endl;

	return 0;
}

Measured memory_bytes: 3564
#include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
using namespace std;
const int MAXX=200100;
int head[MAXX],ver[MAXX<<1],nxt[MAXX<<1],ind[MAXX][2];
int n,m,tot,cnt;
bool vis[MAXX];
char s[MAXX];
queue<int>q;
inline void add(int x,int y){
	s[x]=='A' ? ++ind[y][0] : ++ind[y][1];
	ver[++tot]=y;
	nxt[tot]=head[x];
	head[x]=tot;
}
inline void topsort(){
	for(int i=1;i<=n;++i)if((!ind[i][0])||(!ind[i][1])){
		q.push(i);
		vis[i]=1;
		cnt++;
	}
	while(!q.empty()){
		int x=q.front();
		q.pop();
		for(int i=head[x];i;i=nxt[i]){
			int y=ver[i];
			s[x]=='A' ? --ind[y][0] : --ind[y][1];
            if((!ind[y][0])||(!ind[y][1])){
            	if(vis[y])continue;
            	vis[y]=1;
            	q.push(y);
            	cnt++;
            }
		}
	}
}
int main(){
	scanf("%d%d",&n,&m);
	scanf("%s",s+1);
    for(int i=1;i<=m;++i){
    	int x,y;
    	scanf("%d%d",&x,&y);
    	add(x,y);
    	add(y,x);
    }
    topsort();
    if(cnt==n)printf("No\n");
    else printf("Yes\n");
    return 0;
}

Measured memory_bytes: 6400
import math
a, b, x = map(int, input().split())

if x >= a*a*b/2:
  limit = a*a*b - x
  ans = math.atan(2*limit/(a**3))
  ans = math.degrees(ans)

else:
  ans = math.atan((a*b*b)/(2*x))
  ans = math.degrees(ans)
print(ans)

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

#define int long long

const int LLINF = 1LL << 60;

main()
{

  int n;

  int a[300005];

  int left[100005];
  int right[100005];
  
  cin >> n;

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

  int sum = 0;
  priority_queue < int, vector < int >, greater < int > > pq1;
  priority_queue < int > pq2;
  
  for(int i = 0; i < n; i++) {
    pq1.push(a[i]); sum += a[i];
  }
  for(int i = n; i < n * 2; i++) {
    left[i - n] = sum;
    if(pq1.top() < a[i]) {
      sum += (a[i] - pq1.top());
      pq1.pop(); pq1.push(a[i]);
    }
  }
  left[n] = sum;

  sum = 0;
  for(int i = 3 * n - 1; i >= 2 * n; i--) {
    pq2.push(a[i]); sum += a[i];
  }
  for(int i = 2 * n - 1, k = 0; i >= n; i--, k++) {
    right[k] = sum;
    if(pq2.top() > a[i]) {
      sum += (a[i] - pq2.top());
      pq2.pop(); pq2.push(a[i]);
    }
  }
  right[n] = sum;

  int maxv = -LLINF;
  for(int i = 0; i <= n; i++) {
    maxv = max(maxv, left[i] - right[n - i]);
  }

  cout << maxv << endl;

  return (0);
}


Measured memory_bytes: 6516
#include<bits/stdc++.h>
using namespace std;
int main() {
	int K;
	vector<vector<vector<int>>>dp(11,vector<vector<int>>(10,vector<int>(10,0)));
	vector<vector<int>>sm(11,vector<int>(10,0));
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	for(int i=0;i<10;i++) {
		dp[1][i][i]=1;
		for(int j=2;j<=10;j++)
			for(int k=0;k<10;k++) {
				if(k>0) dp[j][i][k]+=dp[j-1][i][k-1];
            	dp[j][i][k]+=dp[j-1][i][k];
            	if(k<9) dp[j][i][k]+=dp[j-1][i][k+1];
			}
		for(int j=1;j<=10;j++)
			for(int k=0;k<10;k++)
				sm[j][i]+=dp[j][i][k];
	}
	cin>>K;
	K--;
	for(int i=1,j=-1;i>0;) {
		bool ok=0;
		for(int k=0;k<10;k++)
			if((j!=-1||k!=0)&&(j==-1||abs(j-k)<=1))
				if(sm[i][k]>K) {
					cout<<k;
					i--;
					ok=1;
					j=k;
					break;
				}
				else K-=sm[i][k];
		if(!ok) i++;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n; cin >> n;
	int ans = 0;
	for(int i = 1; i <= n; i++){
		int keta = 0, j = i;
		while(j) keta++, j /= 10;
		ans += keta % 2;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

long long int euclid(long long int a,long long int b){
	
	if(a < b)swap(a,b);
	
	long long int r;
	while(b > 0){
		r = a % b;
		a = b;
		b = r;
	  }
	return a;
}
	
int main()
{
	long long int n,a,ans=1;
	
	cin >> n;
	
	for(int i=0;i<n;i++){
		cin >> a;
		ans = (ans/euclid(ans,a))*a;
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll MOD = 1E+09 + 7;
const ll INF = 1E18;
const int MAX_N = 1E+05;

int N;

int X[MAX_N + 1];

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

    cin >> N;

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

    for (int i = 1; i <= N; i++) {
        if (i == X[i]) {
            swap(X[i], X[i + 1]);
            ans++;
        }
    }

    cout << ans << "\n";

    return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(x) cout<<x<<endl

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double PI = acos(-1.0);
const LL MOD = 1e9 + 7;
const ULL INF = 1e18;
const int dx[]{ 1,-1,0,0 }, dy[]{ 0,0,1,-1 };

//function
//--------------------------------------------
LL gcd(LL, LL);
bool isEven(LL);
void coutY();
void coutN();
LL ave(LL, LL);
bool isMultiOf(LL, LL);

int main() {
	int a, b; cin >> a >> b;
	if (a + b >= 10)cout << "error";
	else cout << a + b;
}

LL gcd(LL a, LL b) {
	if (a == 0 || b == 0)return 0;
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	else gcd(b, a % b);
}
bool isEven(LL a) {
	return !((bool)(a % 2));
}
void coutY() {
	cout << "Yes" << endl;
	return;
}
void coutN() {
	cout << "No" << endl;
	return;
}
LL ave(LL a, LL b) {
	return (a + b) / 2;
}
bool isMultiOf(LL a, LL b) {
	return a % b == 0;
}

Measured memory_bytes: 256
#!/usr/bin/env ruby
require 'set'

line = STDIN.read.split("\n")
n = line[0].to_i
dict = Set.new

(1..n).each do |i|
  action, str = line[i].split
  str = str.tr('ACTG', '1234').to_i
  if action == 'insert'
    dict << str
  else
    puts dict.include?(str) ? 'yes' : 'no'
  end
end

Measured memory_bytes: 119884
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc084/tasks/abc084_b

"""
import sys
from sys import stdin
import re
input = stdin.readline


def solve(A, B, S):
    result = 'No'
    pattern = r'^(\d{' + str(A) + '})-(\d{' + str(B) + '})$'
    m = re.search(pattern, S)
    if m:
        result = 'Yes'
    return result


def main(args):
    A, B = map(int, input().split())
    S = input().strip('\n')
    # A, B = 3, 4
    # S = '269-6650'
    ans = solve(A, B, S)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3188
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	long long n , m;
	cin >> n >> m;
	
	long long ans = 0;
	if( 2*n <= m){
		ans += n;
		m -= 2*n;
		ans += m/4;
	}
	else
		ans += m/2;
	
	P(ans);
	ret 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.lang.*;

class Main {

	private static long gcd(long a, long b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

	public static void main(String[] args) {
		final FastScanner sc = new FastScanner(System.in);
		long n = sc.nextLong();
		long k = sc.nextLong();

		if (k == 1) {
			System.out.println(0);
			return;
		}

		Set<Long> s = new HashSet<>();
		n = n % k;
		s.add(n);
		long min = n;
		while (true) {
			if (n == 0) break;
			n = Math.abs(n - k);
			if (s.contains(n)) break;
			s.add(n);
			min = Math.min(min, n);
		}

		System.out.println(min);
	}

	static class FastScanner {
		private final InputStream in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		public FastScanner(InputStream source) {
			in = source;
		}

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte()) return buffer[ptr++];
			else return -1;
		}

		private static boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}
}


Measured memory_bytes: 23252
import java.util.*;

public class Main {

	public static void main(String[] args) {
	
	
		Scanner sc=new Scanner(System.in);
		 int a=sc.nextInt();
		 int b=sc.nextInt();
		 int c=sc.nextInt();
		 
		 System.out.println(b-a==c-b?"YES":"NO");
			
		
	
		
		sc.close();

	}

}


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

const int MAX_LEN=300;

char S[MAX_LEN+1];
int len;

int dp[MAX_LEN+1][MAX_LEN+1];
char out[MAX_LEN+1];

int lcs(int sp){
	int len1=sp;
	int len2=len-sp;
	FOR(i,1,len1+1){
		FOR(j,1,len2+1){
			if (S[i-1]==S[sp+j-1]){
				dp[i][j]=dp[i-1][j-1]+1;
			}
			else{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	return dp[len1][len2];
}

int main(){
	do{
		scanf("%s",S);
		if (S[0]!='#'){
			len=strlen(S);
			int ans=0;
			int sp;
			FOR(i,1,len){
				int l=lcs(i);
				if (l>ans){
					ans=l;
					sp=i;
				}
			}
			lcs(sp);
			int i=sp,j=len-sp;
			stack<char> st;
			while (ans>0){
				if (S[i-1]==S[sp+j-1]){
					ans--;
					st.push(S[i-1]);
					i--;
					j--;
				}
				else{
					if (dp[i-1][j]==dp[i][j]){
						i--;
					}
					else{
						j--;
					}
				}
			}
			while (!st.empty()){
				printf("%c",st.top());
				st.pop();
			}
			printf("\n");
		}
	}while(S[0]!='#');
	return 0;
}

Measured memory_bytes: 1496
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int v = 0;
    int a = 0;
    int b = 0;
    int c = 0;
    for(int i = 0; i < s.length(); i++) {
      if(s.charAt(i) == 'g') {
        if(v == 0) {
          v++;
          b++;
        } else {
          v--;
          a++;
        }
      } else {
        if(v == 0) {
          v++;
          c++;
        } else {
          v--;
          b++;
        }
      }
    }
    System.out.println(a - c);
  }
}

Measured memory_bytes: 25044
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++ 
signed main() {
	int n;
	string s;
	cin>>n>>s;
	int ma=0;
	for(int i=0;i<=n;i++){
		set<char>se;
		for(int j=0;j<i;j++){
			for(int z=i;z<n;z++){
				if(s[j]==s[z]){
					se.insert(s[j]);
				}
			}
		}
		ma=max(ma,(int)se.size());
	}
	cout<<ma<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

int main() {
  //
  string s;
  cin >> s;
  int n = s.size();
  int k;
  cin >> k;
  set<string> st;
  rep(i, n) {
    int jmax = min(n, i + k);
    for (int j = i + 1; j <= jmax; j++) {
      string sub = s.substr(i, j - i);
      if (st.size() == k) {
        if (*(st.rbegin()) > sub && st.find(sub) == st.end()) {
          st.erase(*(st.rbegin()));
          st.insert(sub);
          // cout << sub << endl;
        }
      } else {
        st.insert(sub);
        // cout << sub << endl;
      }
    }
  }
  cout << *(st.rbegin()) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, h[111111];

  std::cin >> N;

  for (int i = 0; i < N; i ++)
    std::cin >> h[i];

  long long dp[111111];

  memset(dp, 0x3f, sizeof(dp));

  dp[0] = 0;

  for (int i = 0; i < N - 1; i ++) {
    if (i + 1 < N)
      dp[i + 1] = std::min(std::abs(h[i + 1] - h[i]) + dp[i], dp[i + 1]);

    if (i + 2 < N)
      dp[i + 2] = std::min(std::abs(h[i + 2] - h[i]) + dp[i], dp[i + 2]);
  }

  std::cout << dp[N - 1] << std::endl;

  return 0;
}


Measured memory_bytes: 1536
fun main(args: Array<String>) {
    val S = next()
    val first = mutableListOf<Char>()
    val last = mutableListOf<Char>()
    val Q = nextInt()
    var reverse = false
    repeat(Q) {
        val query = listOfString()
        when (query[0]) {
            "1" -> {
                reverse = !reverse
            }
            "2" -> {
                when (query[1]) {
                    "1" -> {
                        if (reverse)
                            last.add(query[2][0])
                        else
                            first.add(query[2][0])
                    }
                    "2" -> {
                        if (reverse)
                            first.add(query[2][0])
                        else
                            last.add(query[2][0])
                    }
                }
            }
        }
    }
    val ans = first.reversed().joinToString(separator = "") + S + last.joinToString(separator = "")
    println(if (reverse) ans.reversed() else ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta


Measured memory_bytes: 74568
#include <iostream>
     
using namespace std;
    int group(int x)
    {
        int g;
        if (x==2)
            g=3;
        else if (x==4 || x==6 || x==9 || x==11)
            g=2;
        else
            g=1;
        return g;
    }
    int main()
    {
        int x;
        int y;
        cin >> x >> y;
        if (group(x)==group(y))
            cout << "Yes";
        else
            cout << "No";
        return 0;
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
int main(){
  int n, x, m[1000], sum=0;
  scanf("%d%d", &n, &x);
  for(int i = 0; i < n; i++){
    scanf("%d", &m[i]);
    sum += m[i];
  }
  x-=sum;
  std::sort(m, m+n);
  int ans = n+x/m[0];
  printf("%d\n", ans);
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;
std::string S;
int cnt1[300100], cnt2[300100];

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

    std::cin >> N >> S;

    for(int i=1;i<=N;++i){
        cnt1[i] = cnt1[i - 1];

        if(S[i - 1] == 'W'){
            cnt1[i] += 1;
        }
    }

    for(int i=N;i>=1;--i){
        cnt2[i] = cnt2[i + 1];

        if(S[i - 1] == 'E'){
            cnt2[i] += 1;
        }
    }

    int mn = N;

    for(int i=1;i<=N;++i){
        mn = std::min(mn, cnt1[i - 1] + cnt2[i + 1]);
    }

    std::cout << mn << std::endl;
}


Measured memory_bytes: 2964
#include <iostream>
#include <cmath>

using namespace std;

int main(){
    int A,B,H,M; cin >> A>>B>>H>>M;

    double theta = 2.0*M_PI * (H + M/60.0) / 12.0 - 2*M_PI * M/60;
    if(theta >= M_PI) theta = 2*M_PI - theta;
    double dist = sqrt(A*A+B*B-2*A*B*cos(theta));
    printf("%.20f\n", dist);
}

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

int main() {

    std::string s;
    std::string t;

    std::cin >> s;
    std::cin >> t;

    std::vector<std::vector<int>> dp(s.size()+1, std::vector<int>(t.size()+1, 0));
    std::vector<std::vector<int>> trace(s.size()+1, std::vector<int>(t.size()+1, 0)); // keep track of which we used

    const int UP = 1;
    const int LEFT = 2;
    const int DIAG = 3;

    for (int i = 1; i <= s.size(); i++) {
        for (int j = 1; j <= t.size(); j++) {

            int cur = dp[i-1][j];
            int curDir = UP;

            if (dp[i][j-1] > cur) {
                cur = dp[i][j-1];
                curDir = LEFT;
            }

            if (dp[i-1][j-1] > cur) {
                cur = dp[i-1][j-1];
                curDir = DIAG;
            }

            if (s[i-1] == t[j-1]) {
                if (dp[i-1][j-1]+1 > cur) {
                    cur = dp[i-1][j-1]+1;
                    curDir = DIAG;
                }
            }

            dp[i][j] = cur;
            trace[i][j] = curDir;
        }
    }

    std::string ans = "";

    int i = s.size();
    int j = t.size();
    
    while (i > 0 && j > 0) {
        if (trace[i][j] == DIAG) {
            ans += t[j-1];
            i--;
            j--;
        } else if (trace[i][j] == UP) {
            i--;
        } else {
            j--;
        }
    }

    std::reverse(ans.begin(), ans.end());

    std::cout << ans << "\n";

    return 0;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
//const int mod = 100000;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

ll modpow(ll a, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
int main()
{
  int n, m;
  cin >> n >> m;
  if(abs(n-m) > 1) cout << 0 << endl;
  else {
    mint ans = 1;
    rep(i, n) ans *= i+1;
    rep(i, m) ans *= i+1;
    if(n == m) ans *= 2;
    cout << ans.x << endl;
  }
}

Measured memory_bytes: 3572