akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
using namespace std;
signed main(){
	string o,e;
	cin >> o >> e;
	int n =o.size() + e.size();
	REP(i,n){
		if(i%2 == 0){
			int x = (i/2);
			cout << o[x];
		}else{
			int x = (i/2);
			cout << e[x];
		}
	}
    return 0;
}

Measured memory_bytes: 256
// AtCoder165 C

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <string.h>
#include <memory.h>
#include <malloc.h>
#include <stdlib.h>
#include <ctype.h>

// qsortで用いる比較用関数．*a<*bならaが先になる．
int compare(const void* a, const void* b) {
    return *(int*)a - *(int*)b;
}

int revcompare(const void* a, const void* b) {
    return *(int*)b- *(int*)a;
}

double dmax(double x, double y){
    if(x < y) return y;
    return x;
}

int main() {
    int i,j;
    int n;

    int day;
    int a;
    int x;

    scanf("%d",&n);
    scanf("%d %d", &day, &x);

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

        sum += (day-1) / a + 1;
    }

    printf("%d", sum + x);
    return 0;

}

Measured memory_bytes: 128
<?php

$n = (int)trim(fgets(STDIN));

$j_sum = 0;
$b_sum = 0;
for ($i=0; $i < $n; $i++) { 
	$input = explode(' ', trim(fgets(STDIN)));
	if ($input[1] == 'JPY') {
		$j_sum += (int)$input[0];
	}else{
		$b_sum += (float)$input[0] * 380000;
	}
}
echo $j_sum + $b_sum;

Measured memory_bytes: 4728
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
int Ceil(int a,int b){return ((a%b==0)?a/b:a/b+1);}
const int INF=9223372036854775800;
const int MOD=1000000007;

int N,K;
int X[51],Y[51];
P p[51];
int T[51];
int ans=INF;

signed main(){
	cin>>N>>K;
	REP(i,N){
		cin>>X[i]>>Y[i];
	}
	REP(i,N){
		REP(j,N){
			REP(k,i){
				REP(l,j){
					int kx=min(X[i],X[k]);
					int lx=max(X[i],X[k]);
					int ky=min(Y[j],Y[l]);
					int ly=max(Y[j],Y[l]);
					int cnt=0;
					REP(m,N){
						if(kx<=X[m]&&X[m]<=lx&&ky<=Y[m]&&Y[m]<=ly){
							cnt++;
						}
					}
					if(cnt>=K){
						ans=min(ans,abs((lx-kx)*(ly-ky)));
					}
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define ll long long

void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


int gcd(int a, int b){
  int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

int upll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;
}

int downll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;
}

void sortup(ll*a,int n){
  qsort(a,n,sizeof(ll),upll);
}

void sortdown(ll*a,int n){
  qsort(a,n,sizeof(ll),downll);
}

long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  int r,g,b,n;
  scanf("%d%d%d%d",&r,&g,&b,&n);

  int ans=0;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      int now=i*r+j*g;

      if((n-now)%b==0 && now<=n){
        ans++;
      }
    }
  }

  printf("%d\n",ans);

  return 0;
}

Measured memory_bytes: 1696
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <map>
using namespace std;
const int MaxN = 1e5;
const int oo = 1 << 30;
const int mod = 1e9 + 7;
typedef long long LL;

LL n, m;
int main()
{
	while(scanf("%lld %lld", &n, &m) != EOF)
	{
		LL ans = 0;
		if(m < 2 * n) ans = m / 2;
		else if(m == 2 * n) ans = n;
		else 
		{
			m = m - 2 * n;
			ans = n + m / 4;
		}
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
    int X, Y, Z;

    scanf("%d%d%d", &X, &Y, &Z);

    swap(X, Y);
    swap(X, Z);

    printf("%d %d %d", X, Y, Z);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
    string s,a,u;
    int t,b;
    cin >>s>>a;
    cin>>t>>b;
    cin>>u;
    if (u==s){
        cout<<t-1<<' '<<b<<endl;
    }
    else{
        cout<<t<<' '<<b-1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef double long dl;
typedef pair < int , int > pii;
typedef pair < pii, pii > p2i;
const int maxn = (int) 1e5 + 2;
const int mod = (int) 1e9 + 7;
const ll inf = (ll)1e18;
 
#define fi first
#define se second
#define acel ios_base :: sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define next continue
#define getsz(x) (int) log10(x)
 
int n, m;
int a[maxn];
int x, y, t;
int u[maxn];
vector < int > g[maxn];
map < int, int > w[maxn];
void dfs(int v, int p){
    u[v] = t;
    w[t][a[v]] = 1;
    for(int i : g[v]){
        if(i == p){
            next;
        }
        if(!u[i]){
           dfs(i, v);
        }
    }
}
 
int ans;
int main(){
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    for(int i = 1; i <= m; i++){
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    for(int i = 1; i <= n; i++){
        if(!u[i]){
            t++;
            dfs(i, i);
        }
    }
    for(int i = 1; i <= n; i++){
        ans += w[u[i]][i];
    }
    cout << ans;
}

Measured memory_bytes: 20864
fun main(){
    val (a,b,k) = readLine()!!.split(" ").map{it.toLong()}
    val ans1 = Math.max(a-k,0)
    var ans2:Long
    if(ans1 == 0.toLong()){
        ans2 = Math.max(b-k+a,0)
    }else{
        ans2 = b
    }
    println("%s %s".format(ans1,ans2))
}

Measured memory_bytes: 37392
/* ex 4_1
   cy_an  */

#include <stdio.h>
#include <math.h>

int main(void){
    int num_N, work_D, staff;           // 変数宣言
    scanf("%d %d", &num_N, &work_D);    // 入力

    staff = (num_N / (1 + 2 * work_D)); // staffの計算
    if(num_N % (1 + 2 * work_D) == 0){  // 余りが0のとき
        printf("%d\n", staff);            // staffを出力
    }else{                              // 余りが0でないとき
        printf("%d\n", ++staff);          // staffに1を足して出力
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  string s;
  cin >> s;
  int n = s.size();
  if (n % 2 != 0) {
    cout << "No" << endl;
    return;
  }
  REP(i, n) {
    if (i % 2 == 1) continue;
    if (s.substr(i, 2) != "hi") {
      cout << "No" << endl;
      return;
    }
  }
  cout << "Yes" << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

const int mod=1e9+7;

struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  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*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};

mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}

map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}

void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}

int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );

  int a,b,k;
  cin>>a>>b>>k;
  
  int c=a;
  if(a>b)c=b;
  int cnt=0;
  int ans=0;
  rreps(i,c){
    if(a%i==0&&b%i==0)cnt++;
    if(cnt==k){
      ans=i;
      break;
    }
  }

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 125568
#!/usr/bin/env ruby

require 'bigdecimal'
require 'bigdecimal/math'
include BigMath

a, b, h ,m = gets.chomp.split(' ').map(&:to_s)

rad_a = -(BigDecimal(h) + BigDecimal(m) / 60) / 12 * ( 2 * Math::PI)
rad_b = -(BigDecimal(m) / 60) * ( 2 * Math::PI)

prec = 10
a_x = cos(rad_a, prec) * 0 - sin(rad_a, prec) * a.to_i
a_y = sin(rad_a, prec) * 0 + cos(rad_a, prec) * a.to_i

b_x = cos(rad_b, prec) * 0 - sin(rad_b, prec) * b.to_i
b_y = sin(rad_b, prec) * 0 + cos(rad_b, prec) * b.to_i

# puts a_x
# puts a_y
# puts b_x
# puts b_y
puts Math.sqrt((a_x - b_x) ** 2 + (a_y - b_y) ** 2)



Measured memory_bytes: 14548
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AEatingSymbolsEasy solver = new AEatingSymbolsEasy();
        solver.solve(1, in, out);
        out.close();
    }

    static class AEatingSymbolsEasy {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            char[] chars = in.next().toCharArray();
            int count = 0;
            for (char c : chars) {
                count += c == '+' ? 1 : -1;
            }
            out.println(count);
        }

    }
}



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

int counter(ll x)
{
    int count=0;
    while(x>=1)
    {
        x=x/10;
        count++;
    }
    return count;
}

double round(double src, int n)
{
    double dst;
    
    dst = src * pow(10, -n - 1);          /*処理を行う桁を10-1 の位にする*/
    dst = (double)(int)(dst + 0.5);
    
    return    dst * pow(10, n + 1);       /*処理を行った桁を元に戻す*/
}
int main()
{
    /*A
    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
    */
    /*B
    int n;
    cin>>n;
    vector <ll> a(n);
    ll sum=1;
    bool flag = 1;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]==0)
        {
            flag = 0;
        }
    }
    if(!flag)
    {
        cout<<0<<endl;
        return 0;
    }
    for(int i=0;i<n;i++)
    {
        ll temp = 1;;
        temp *= sum*a[i];
        if(temp<sum || temp>1000000000000000000)
        {
            cout<<-1<<endl;
            return 0;
        }
        else
        {
            sum=temp;
        }
    }
    cout<<sum<<endl;
    */

    /*C
    ll a;
    double b;
    cin>>a>>b;
    ll b_int = b*100+0.5;
    a*=b_int;
    cout<<a/100<<endl;
    */

    ll a;
    double b;
    cin>>a;
    cin>>b;
    int b_int = b*100+0.1;
    cout<<ll(a*b_int)/100<<endl;
    
    /*if(b_int>1)
    {
        b_decimal = double(b-b_int);
    }
    else
    {
        b_decimal = b;
    }
    
    ll sum=0;
    sum+=a*b_int;
    cout<<b_decimal;
    ll ab_int = ll(a*(b_decimal));
    sum+=ab_int;
    cout<<sum<<endl;
    */

    return 0;
}

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

int main() {

  int n;
  cin >> n;
  vector<long long> vector;  
  long long temp;

  for(int i=0; i<n; i++) {
    cin >> temp;
    vector.push_back(temp);
  }

  long long answer1=0;
  long long answer2=0;
  long long sum1=0;
  long long sum2=0;

  for(int i=0; i<n; i++) {
    if(i == 0) {
      if(vector[0] > 0)
	sum1 = vector[0]; //初項
      else {
	sum1 = vector[0];
	while(sum1 <= 0) {
	  sum1++;
	  answer1++;
	}
      }
    }
    else if(sum1 < 0) {
      sum1 += vector[i];
      if(sum1 <= 0){ //和の符号がデフォルトで異なるとき
	// answer -> そのまま
	while(sum1 <=0) {
	  sum1++;
	  answer1++;
	}
      }
    }
    else {
      sum1 += vector[i];
      if(sum1 >= 0){ //和の符号がデフォルトで異なるとき
	// answer -> そのまま
	while(sum1 >=0) {
	  sum1--;
	  answer1++;
	}
      }
    }
  }

  for(int i=0; i<n; i++) {
    if(i == 0) {
      if(vector[0] < 0)
	sum2 = vector[0]; //初項
      else {
	sum2 = vector[0];
	while(sum2 >= 0) {
	  sum2--;
	  answer2++;
	}
	/*sum1 = 1;
	  answer1 += abs(1-vector[0]);
	  */
      }
    }
    else if(sum2 < 0) {
      sum2 += vector[i];
      if(sum2 <= 0){ //和の符号がデフォルトで異なるとき
	// answer -> そのまま
	while(sum2 <=0) {
	  sum2++;
	  answer2++;
	}
      }
    }
    else {
      sum2 += vector[i];
      if(sum2 >= 0){ //和の符号がデフォルトで異なるとき
	// answer -> そのまま
	while(sum2 >=0) {
	  sum2--;
	  answer2++;
	}
      }
    }
  }
  cout << min(answer1,answer2) << endl;
  return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define N 310
LL read(){
	LL x=0,f=1;
	char ch=getchar();
	while (ch<'0' || ch>'9'){
		if (ch=='-') f=-1;
		ch=getchar();
	}
	while (ch>='0' && ch<='9'){
		x=x*10+ch-'0';ch=getchar();
	}
	return x*f;
}
int n,m,a[N],b[N];
LL sum,cnt,f[N][35];
LL solve(){
	for (int i=1;i<=n*m;++i){
		for (int j=0;j<1<<n-1;++j) f[i][j]=0;
	}
	f[n*a[n-1]][0]=1;
	for (int i=0;i<n*m;++i){
		for (int j=i;j<=n*m;++j){
			for (int k=0;k<1<<n-1;++k){
				if (i%n && !(k>>b[i%n-1]&1)){
					f[min(n*m,max(j,i+n*a[b[i%n-1]]))][k|1<<b[i%n-1]]+=f[j][k];
				}
			}
		}
	}
	return f[n*m][(1<<n-1)-1];
}
signed main(){
	n=read(),m=read();
	for (int i=0;i<n;++i) a[i]=read();
	sort(a,a+n);
	for (int i=0;i<n-1;++i) b[i]=i;
	do{
		sum+=solve();cnt++;
	}while (next_permutation(b,b+n-1));
	for (int i=0;i<n-1;++i) cnt=cnt*m;
	printf("%.12lf\n",(double)sum/cnt);
	return 0;
}

Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = input.nextInt();
		}
		int UP = Integer.MIN_VALUE;
		int DOWN = Integer.MIN_VALUE;
		Arrays.sort(arr);
		/*for (int TOP = 0; TOP < N; TOP++) {
			for (int BOT = TOP+1; BOT<N; BOT++) {
				int Num = Math.max(arr[TOP], arr[BOT]);
				int Den = Math.min(arr[TOP], arr[BOT]);
				if (Num>=UP&&Den>=DOWN&&Num-Den>=UP-DOWN) {
					UP=Num;
					DOWN=Den;
				}
			}
		}*/
		int LDiff = 0;
		int RDiff = Integer.MAX_VALUE;
		for (int i = 0; i < N-1; i++) {
			int L = arr[i];
			int R = arr[N-1]-arr[i];
			if (Math.abs(L-R)<Math.abs(RDiff-LDiff)) {
				RDiff = arr[N-1]-arr[i];
				LDiff = arr[i];
				DOWN=arr[i];
			}
		} 
		System.out.println(arr[N-1]+" "+DOWN);
		//for int i = 0
	}
}

Measured memory_bytes: 50580
c = []
c.append(list(map(int, input().split())))
c.append(list(map(int, input().split())))
c.append(list(map(int, input().split())))

if c[0][0] - c[1][0] == c[0][1] - c[1][1] == c[0][2] - c[1][2] and c[1][0] - c[2][0] == c[1][1] - c[2][1] == c[1][2] - c[2][2]:
    print("Yes")
else:
    print("No")
    


Measured memory_bytes: 3064
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_map>

int main()
{
    int a, b, c;
    std::cin >> a >> b >> c;

    int cnt = 0;
    if ((c - 1) <= b) {
        cnt += (b + c);
    } else {
        cnt += (b * 2 + 1);
        c -= (b + 1);

        if (c <= a) {
            cnt += c;
        } else {
            cnt += a;
        }
    }

    std::cout << cnt << std::endl;

    return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int A = scan.nextInt();
		int B = scan.nextInt();
		int c = scan.nextInt();
		int[] Di = new int[N];
		int y = 0, k = 0;
		double x = 0.0, pizza = 0.0;
		
		for(int i = 0; i < N; i++){
			Di[i] = scan.nextInt();
		}
		Arrays.sort(Di);
		
		pizza = (c + y) / (A + B * k);   //生地のみの１ドルあたりのカロリー
		for(int i = N-1; i >= 0; i--){
			y += Di[i];   //トッピングをのせていく
			k++;   //トッピング数をカウント
			x = (c + y) / (A + B * k);
			if(pizza <= x){
				pizza = x;
			}else break;
		}
		
		System.out.println((int)pizza);
	}
}

Measured memory_bytes: 18168
#include <bits/stdc++.h>
#define PI 3.1415926535897932384626433832795028841971
using namespace std;
double a,b,h,m,u1,u2,u,coss,c;
string s;
int main()
{
    cin>>a>>b>>h>>m;
    u1=(h*60+m)*0.5;
    u2=m*6;
    u=abs(u1-u2);
    if(u>180)
        u=360-u;
    coss=cos(u*PI/180.0);
    c=sqrt(a*a+b*b-2*a*b*coss);
    cout<<fixed<<setprecision(100)<<c;
    return 0;
}


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

int N,K;
int a[100001];

void solve(){
    for(int i=0;i<N;i++){
        scanf("%d",&a[i+1]);
        a[i+1]+=a[i];
    }
    int ma=0;
    for(int i=K;i<=N;i++)ma=max(ma,a[i]-a[i-K]);
    printf("%d\n",ma);
}
int main(){
    while(scanf("%d%d",&N,&K),N||K)solve();
}

Measured memory_bytes: 1572
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    int n,k;
    cin>>n>>k;
    vector<int> v[n];
    unordered_map<int,unordered_set<int>> E;


    rep(i,n){
        for(int j=0;j<n;j++){
           if(i!=j){
               E[i].insert(j);
           }
        }
    }
    if(k>(n-1)*(n-2)/2){
        cout<<-1<<endl;
    }else{
        int now = 0;
        bool f = false;
        for(int i=1;i<n;i++){
            for(int j=i+1;j<n;j++){
                if(now==k){
                    f = true;
                    break;
                }else{
                    now++;
                    E[i].erase(j);
                    E[j].erase(i);
                }
            }
            if(f)break;
        }

        int m = 0;
        for(auto &&a:E){
            m+=a.second.size();
        }
        m/=2;
        cout<<m<<endl;
        unordered_set<int> out;
        for(auto &&b:E){
            int u = b.first;
            out.insert(u);
            for(auto &&v:b.second){
                if(out.count(v) == 0){
                    cout<<u+1<<" "<<v+1<<endl;
                }
            }
        }

    }










    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    int a,b,c,d;
    cin>>a>>b>>c;
    if(a+b>=c)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N, H;
    cin >> N >> H;

    vector<P> NH(2 * N);
    rep(i, N) {
        int a, b;
        cin >> a >> b;
        NH[i] = P(a, 0);
        NH[N + i] = P(b, 1);
    }

    sort(all(NH));
    reverse(all(NH));

    ll ans = 0;

    rep(i, 2 * N) {
        if (NH[i].second == 0) {
            ans += (ll)(H / NH[i].first);
            if (H % NH[i].first != 0) ans++;
            break;
        }
        else {
            H -= NH[i].first;
            ans++;
        }
        if (H <= 0) break;
    }

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

Measured memory_bytes: 1792
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    a, b, x = nm()

    if x <= a + b and x >= a:
        print('YES')
    else:
        print('NO')


if __name__ == '__main__':
    main()

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> a(n),b(n);
	int right = -1;
	int left  = -1;
	int mx = 0;
	int mn = inf;
	rep(i,n){
		cin >> a[i] >> b[i];
		if(mn>b[i]){
			mn = min(mn,b[i]);
			right = a[i];
		}
		if(mx<b[i]){
			left = a[i];
			mx = b[i];
		}
	}
	ll ans = 1+(right - left);
	ans += left - 1;
	ans += mn;
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
using namespace std;

bool poor(int A, int B, int C) {
    return (A==B) && (B!=C);
}

int main() {
    int A;
    int B;
    int C;

    cin >> A >> B >> C;

    if (poor(A, B, C) || poor(A, C, B) || poor(B, C, A)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	h := make([]int, N)
	for i := range h {
		fmt.Scan(&h[i])
	}
	ans := 0
	seed := true
	for seed {
		on := false
		seed = false
		for i := 0; i < N; i++ {
			if h[i] > 0 {
				if !on {
					on = true
					ans++
					seed = true
				}
				h[i]--
			} else {
				on = false
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
S = str(input())
l = len(S)

if l % 2 == 0:
  A = S[:(l//2)]
  B = S[(l//2):]
else:
  A = S[:(l//2)]
  B = S[(l//2+1):]
  
B = B[::-1]
ans = 0
for i in range(l//2):
  if A[i] != B[i]:
    ans += 1
    
print(ans)

Measured memory_bytes: 9124
from collections import deque

def main():
  N=int(input())
  A=[deque(int(a)-1 for a in input().split()) for _ in range(N)]

  P,W=[0]*N,[-1]*N
  c=deque(range(N))

  while c:
    i=c.popleft()
    j=A[i].popleft()
    W[i]=j

    if W[j]==i:
      P[i]=P[j]=max(P[i],P[j])+1
      if A[i]:
        c.append(i)
      if A[j]:
        c.append(j)

  print(-1 if any(len(a) for a in A) else max(P))

main()


Measured memory_bytes: 35948
fun main(args: Array<String>) {
    val n = readLong()
    
    if (n % 2 == 1L) {
        println(0)
        return
    }
    
    var ans = 0L
    var i = 5L
    while (i <= n) {
        ans += (n / i) / 2
        i *= 5
    }
    println(ans)
}


fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 29824
#include <bits/stdc++.h>
using namespace std;
int main() {
    int D;
    cin >> D;

    switch (D) {
    case 25:
        cout << "Christmas" << endl;
        break;
    case 24:
        cout << "Christmas"
             << " "
             << "Eve" << endl;
        break;
    case 23:
        cout << "Christmas"
             << " "
             << "Eve"
             << " "
             << "Eve" << endl;
        break;
    case 22: cout << "Christmas"
                  << " "
                  << "Eve"
                  << " "
                  << "Eve"
                  << " "
                  << "Eve" << endl;
    default:
        break;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)

int main() {

    int N, M; cin >> N >> M;
    vector<vector<int> > vec(N+2, vector<int>(N+2, 0));
    rep(i, M) {
        int x, y; cin >> x >> y;
        vec[x][y] = 1; vec[y][x] = 1;
    }

    vector<int> order(N-1);
    rep (i, N-1) order[i] = i + 2;

    int sum = 0;

    do {

        int former = 1, next, flg = 1;

        for (int i : order){

            next = i;

            if (!vec[former][next]){
                flg = 0; break;
            }

            former = next;
        }

        if (flg) sum++;
    } while(next_permutation(order.begin(), order.end()));

    cout << sum << endl;
    return 0;

}

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

int main(){
	
	char ch[8] = {'0', '1', '2', '3', '5', '7', '8', '9'};
	int n;
	
	while( cin >> n, n ){
		string s;
		do{
			s.push_back( ch[n % 8] );
			n /= 8;
		}while( n > 0 );
		reverse( s.begin() , s.end() );
		cout << s << endl;
	}
}

Measured memory_bytes: 1192
S = input()
S1 = int(S[:2])
S2 = int(S[2:])
f1 = 0
f2 = 0

if S1 <= 12 and S1 > 0:
        f1 = 1
if S2 <= 12 and S2 > 0:
        f2 = 1
if f1 and f2:
        print("AMBIGUOUS")
elif f1 == 1 and f2 == 0:
        print("MMYY")
elif f1 == 0 and f2 == 1:
        print("YYMM")
else :
        print("NA")


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int N;
int main() {
  cin >> N;
  
  int sum = 0;
  while (N--) {
    int a;
    cin >> a;
    while (a % 2 == 0) {
      a /= 2;
      ++sum;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<set>
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define lowbit(x) (x& -x)
#define inf 0x3f3f3f3f
#define eps 1e-18
#define maxn 2000010
inline ll read(){ll tmp=0; char c=getchar(),f=1; for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1; for(;'0'<=c&&c<='9';c=getchar())tmp=(tmp<<3)+(tmp<<1)+c-'0'; return tmp*f;}
inline ll power(ll a,ll b){ll ans=1; for(;b;b>>=1){if(b&1)ans=ans*a%mod; a=a*a%mod;} return ans;}
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline void swap(int &a,int &b){int tmp=a; a=b; b=tmp;}
using namespace std;
char s[110];
ll n,k;
int main()
{
	scanf("%s",s); n=strlen(s);
	k=read();
	int tmp=0;
	while(s[tmp]=='1'&&k>1)++tmp,--k;
	printf("%c",s[tmp]);
}

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

int N,M;
const int Inf = 10000*100000+100;


int main(){
	while(cin >> N >> M && N>0){
		vector< vector< pair<int,int> > > v(M+10);
		int K[110][110];
		for(int i=0;i<N+1;i++){
			for(int j=0;j<N+1;j++){
				K[i][j] = Inf;
				if(i == j) K[i][j] = 0;
			}
		}
		for(int i=0;i<M;i++){
			int s,t,d;
			cin >> s >> t >> d;
			K[s][t] = d;
			K[t][s] = d;
			v[s].push_back(make_pair(t,d));
			v[t].push_back(make_pair(s,d));
		}
		for(int k=1;k<N+1;k++){
			for(int i=1;i<N+1;i++){
				for(int j=1;j<N+1;j++){
					if(K[i][j] > K[i][k] + K[k][j]) K[i][j] = K[i][k] + K[k][j];
				}
			}			
		}
		//cout << K[1][2] << endl;
		//cout << K[1][3] << endl;
		//cout << K[2][3] << endl;
		bool pass[N+10][N+10] = {{0}};
		for(int s=1;s<N+1;s++){
			for(int i=0;i<v.size();i++){
				for(int j=0;j<v[i].size();j++){
					pair<int,int> t = v[i][j];
					if(K[s][i] + t.second == K[s][t.first]) pass[i][t.first] = true;
				}
			}
		}
		//cout << pass[1][1] << endl;
		int count = 0;
		for(int i=1;i<N;i++){
			for(int j=i+1;j<N+1;j++){
				if(pass[i][j]) count++;
			}
		}
		cout << M-count << endl;
	}
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define pi 2*asin(1.0)


//template functions
/////////////////////////
long Comb(long N,long M){// nCm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
for(long i=M;i>0;i--){
    ans=ans/i;
}
return ans;
}
long Perm(long N,long M){// nPm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
return ans;
}
long GCM(long A,long B){
            long W,r;
    if(A<B){

        W=B;
        B=A;
        A=W;
    }
    while(A%B!=0){
        r=A%B;
        A=B;
        B=r;
    }
    return B;
}
long LCM(long A,long B){
    return (A*B)/GCM(A,B);
}

long upDiv(long a,long b){
  return (a+b-1)/b;
}

/////////////////////////


//Answer


int main() {

long N,flag=1;
string S;
cin>>N>>S;
if(N%2!=0){
    cout<<"No"<<endl;
}else{
    for(long i=0;i<N/2;i++){
        if(S.at(i)!=S.at(i+N/2)){
            flag=0;
            break;
        }  
    }
if(flag==0){
    cout<<"No"<<endl;
}else{
    cout<<"Yes"<<endl;
}

}




}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)

using namespace std;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

int main()
{
  int n;
  cin>>n;
  vecint a(n), b(n);
  REP(i,n) cin>>a[i];
  REP(i,n) cin>>b[i];
  ll cnt = 0;
  queue<int> q;
  REP(i,n) q.push(i);
  while (!q.empty()) {
    int idx = q.front();
    q.pop();
    int prv = (idx+n-1)%n;
    int nxt = (idx+1)%n;
    int s = b[prv] + b[nxt];
    if (b[idx] > s) {
      if (b[idx] - s >= a[idx]) {
        int k = (b[idx] - a[idx]) / s;
        b[idx] -= (b[prv] + b[nxt]) * k;
        cnt += k;
        q.push(prv);
        q.push(nxt);
      }
    }
  }
  if (b == a) {
    cout<<cnt<<endl;
  } else {
    cout<<-1<<endl;
  }
  return 0;
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 2e9
#define LINF 1e18
#define MOD 1000000007
#define PI 3.141592653589793
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define input(x, n)for(ll i = 0; i <(ll)(n); i++)cin >> x[i];
#define until(i,n) for(ll i = 1; i <= (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << "=" << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl

int main(){
    ll n;
    cin >> n;
    int ans = 0;
    until(i, n){
        ll a = i;
        int cnt = 0;
        while(a > 0){
            a/=10;
            cnt++;
        }
        if(cnt%2 == 1)ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3552
def f(N, K):
    M, R = N // 10, N % 10
    if K == 0:
        return 1
    elif M == 0 and K == 1:
        return R
    elif M == 0 and K != 1:
        return 0
    else:
        return R * f(M, K-1) + (9-R) * f(M-1, K-1) + f(M, K)


N = int(input())
K = int(input())
print(f(N, K))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int n,a[105];
int is_ok(int x)
{
	int s=0;
	for(int i=1; i<=n; i++)
		s+=((a[i]-x)*(a[i]-x));
	return s;
 } 
int main()
{
	int i,v=2e9,ans=0;
	cin>>n;
	for(i=1; i<=n; i++)
		cin>>a[i];
	sort(a+1,a+n+1); 
	for(i=a[1]; i<=a[n];i++)
		if(is_ok(i)<v)
		{
			v=is_ok(i);
			ans=v;
		}
		
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<lint> a(n), b(n); for (int i = 0; i < n; ++i) cin >> a[i] >> b[i];
  V<> idx(n);
  iota(begin(idx), end(idx), 0);
  sort(begin(idx), end(idx), [&](int i, int j) { return b[i] < b[j]; });
  lint t = 0;
  for (int i : idx) {
    t += a[i];
    if (t > b[i]) return cout << "No" << '\n', 0;
  }
  cout << "Yes" << '\n';
}

Measured memory_bytes: 4224
import sys

sys.setrecursionlimit(10000000)
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue

# import fractions

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = il()
    A = set(iln(M))
    dp = [0]*(N+1)
    dp[0] = 1

    for n in range(1, N+1):
        if n in A:
            dp[n] = 0
        else:
            dp[n] = (dp[n-1] + dp[n-2])%MOD
    print(dp[N]%MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14140
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, n) for(int i=n; i>=0; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e18
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> T vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> T adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    ll res = 0;
    if(a + b > 2*c){
        if(x > y){
            res = 2*c*y + a*(x-y);
        }else{
            res = 2*c*x + b*(y-x);
        }
        ll tmp = (x>y) ? x : y;
        res = min(2*c*tmp, res);
    }else{
        res = a*x + b*y;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = readContents 2 >>= print . solve

solve :: [[Int]] -> Int
solve [[n, x], as] = check 0 as
    where
        check acc (a : b : cs)
            | s <= x = check acc $ b : cs
            | s - x <= b = check (acc + s - x) $ b - s + x : cs
            | otherwise = check (acc + s - x) $ 0 : cs
            where
                s = a + b
        check acc _ = acc 

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 3068
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
a=list(map(int,input().split()))
cnt=Counter(a)
if len(cnt)>2:
    print("No")
    quit()

if len(cnt)==1:
    if n==a[0]+1 or a[0]*2<=n:
        print("Yes")
    else:
        print("No")
    quit()

syo=cnt[min(a)]
dai=cnt[max(a)]
if max(a)-min(a)!=1:
    print("No")
    quit()
maru=max(a)-syo
if maru<=0:
    print("No")
elif maru*2<=dai:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 101696
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;
int sumdigit(int n){
  int res = 0;
  while(n>0){
    res += n%10;
    n /= 10;
  }
  return res;
}

int main(int argc, char const *argv[]) {
  int n;cin>>n;
  int res = 1<<30;
  for(int i=1;i<n;++i){
    res = min(res, sumdigit(i) + sumdigit(n-i));
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
r, s, p = map(int, input().split())
machine_hands = list(input())
my_hands = []
ans = 0
for idx, m in enumerate(machine_hands):
      if m == 'r':
        my_hands.append('p')
        ans += p
        tmp = p
      elif m == 's':
        my_hands.append('r')
        ans += r
        tmp = r
      elif m == 'p':
        my_hands.append('s')
        ans += s
        tmp = s
      if (idx >= k) and (my_hands[-1] == my_hands[idx-k]):
        my_hands[-1] = '-'
        ans -= tmp

print(ans)


Measured memory_bytes: 4792
import Control.Applicative
import Data.List

main = do
  [w, h, x, y, r] <- map ( read :: String -> Int ) . words <$> getLine
  let horizontal = r <= x && x <= w-r
  let vertical = r <= y && y <= h-r
  let result  | horizontal && vertical = "Yes"
              | otherwise = "No"
  putStrLn $ result




Measured memory_bytes: 3632
a, b, h, m = gets.split.map(&:to_f)
h_rad = 2 * Math::PI * ((h * 60.0 + m) / 720.0)#fだから.0が必須
m_rad = 2 * Math::PI * (m / 60.0)
#Θを求める。Math.cosのΘの部分はラジアンで表す(2πが360度)
puts Math.sqrt(a * a + b * b - 2.0 * a * b * Math.cos(m_rad - h_rad))


Measured memory_bytes: 14676
def f(v):
    n=0
    for i in range(len(v)-1):
        n+=v[i]
        if n<=0:return False
    return True

n,W,H=map(int,input().split())
w=[0]*(W+1)
h=[0]*(H+1)
for _ in [0]*n:
    x,y,a=map(int,input().split())
    w[max(0, x - a)]+=1
    w[min(W, x + a)]-=1
    h[max(0, y - a)]+=1
    h[min(H, y + a)]-=1
print(['No','Yes'][f(w)or f(h)])

Measured memory_bytes: 10124
import numpy as np
H,W,D = map(int,input().split())
a = [input().split() for l in range(H)]
basyo = [[0,0] for i in range(H*W)]
for i in range(W):
  for j in range(H):
    basyo[int(a[j][i])-1] = [j,i]
Q = int(input())
b = [input().split() for l in range(Q)]
ans = []
memo = [0] * (H*W+1)
for i in range(D):
  while i < H*W:
    i += D
    if i >= H*W:
      break
    memo[i] = memo[i-D]  + abs(basyo[i][0] - basyo[i-D][0]) + abs(basyo[i-D][1] - basyo[i][1])
b = np.array(b)
b = np.int64(b)
for i in range(Q):
  syo = b[i,0]
  go = b[i,1]
  print(memo[go-1] - memo[syo-1])

Measured memory_bytes: 68816
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

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




/******************************************************************************************/

ll sum[200005];


int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

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

	for (int i = 1; i <= n; i++)
	{
		sum[i] = sum[i - 1] + a[i - 1];
	}
	
	ll ans = 1LL << 60;


	int left = 1, center = 2,right = 3;
	while(center < n - 1)
	{

		while (left < center) {
			if (abs(sum[left] - (sum[center] - sum[left])) > abs(sum[left + 1] - (sum[center] - sum[left + 1]))) {
				left++;
			}
			else
			{
				break;
			}
		}
		
		while (right < n) {
			if (abs(sum[n] - sum[right] - (sum[right] - sum[center])) > abs(sum[n] - sum[right + 1] - (sum[right + 1] - sum[center]))) {
				right++;
			}
			else
			{
				break;
			}
		}

		ll mini = min(min(sum[left], sum[center] - sum[left]), min(sum[right] - sum[center], sum[n] - sum[right]));
		ll maxi = max(max(sum[left], sum[center] - sum[left]), max(sum[right] - sum[center], sum[n] - sum[right]));
		ans = min(ans, maxi - mini);
		center++;
	}

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 2560
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;

class Main {
    public static Scanner sc = new Scanner(in);
    //public static Random sc=new Random();

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


    public int dfs(int px,int py,int depth){
    	if(depth>10)return Integer.MAX_VALUE;

    	int mv=Integer.MAX_VALUE;
    	D:for(int d=0;d<4;d++){
    		int nx=px,ny=py;
    		int move=0;
    		while(map[ny][nx]!=1){
    			if(map[ny][nx]==3)
    				return depth;

    			nx+=dx[d];ny+=dy[d];
    			move++;
    			if(!(0<=nx && nx <W) || !(0<= ny && ny <H))
    				continue D;
    		}
    		//衝突した時
    		if(move>=2){
	    		map[ny][nx]=0;
	    		mv=min(mv,dfs(nx-dx[d],ny-dy[d],depth+1));
	    		map[ny][nx]=1;
    		}
    	}
    	return mv;
    }

    int[][] map;
    int W,H;
    public void run() {
    	while(true){
    		W=sc.nextInt();H=sc.nextInt();
    		if(W==0 && H==0)return;

    		map=new int[H][W];

    		for(int h=0;h<H;h++)for(int w=0;w<W;w++){
        			map[h][w]=sc.nextInt();
        	}

    		for(int h=0;h<H;h++)for(int w=0;w<W;w++)
        			if(map[h][w]==2){
        				int res=dfs(w,h,1);
        				ln(res==Integer.MAX_VALUE?-1:res);
        				continue;
        			}
    	}
    }
    public static void main(String[] args) {
        new Main().run();
    }

    public int[] nextIntArray(int n){
        int[] res=new int[n];
        for(int i=0;i<n;i++){
            res[i]=sc.nextInt();
        }
        return res;
    }


	//output lib
	public static void pr(Object... obj){
		out.print(str(obj));
	}
    public static void ln(){
		out.println();
	}
	public static void ln(Object... obj){
		pr(obj);ln();
	}
	public static String str(Object obj){
		return obj.toString();
	}
	public static <E> String str(E[] obj){
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<obj.length;i++){
			sb.append(i==0?"":" ").append(obj[i]);
		}
		return sb.toString();
	}
	public static <E> String str(List<E> obj){
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<obj.size();i++){
			sb.append(i==0?"":" ").append(obj.get(i));
		}
		return sb.toString();
	}
}

Measured memory_bytes: 37968
import java.util.Scanner;

public class Main {
    //B - Distance
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        double D = scan.nextDouble();

        int overCount = 0;

        while (N-- > 0) {
            double X = scan.nextDouble();
            double Y = scan.nextDouble();
            double dis = Math.sqrt(Math.pow(X, 2) + Math.pow(Y, 2));
            if (dis <= D) {
                overCount++;
            }
        }
        System.out.println(overCount);
    }
}

Measured memory_bytes: 63608
def main():
    N, L = list(map(int, input().split()))

    taste = [L+i-1 for i in range(1, N+1)]
    abs_taste = [abs(x) for x in taste]
    delete_index = abs_taste.index(min(abs_taste))
    taste.pop(delete_index)
    print(sum(taste))

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384