akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int maxn=100005;

long long dp[maxn];
long long mi[maxn];
long long x[maxn];
int q[maxn],head,tail;
int main()
{
    int n,e,t;
    scanf("%d%d%d",&n,&e,&t);
    for(int i=1;i<=n;i++)
        scanf("%d",x+i);
    dp[n]=1LL*e-x[n]+t;
    head=tail=0;
    long long mi=5000000000000000000LL;
    q[tail++]=n;
    dp[n+1]=0;
    x[n+1]=e;
    for(int i=n-1;i;i--)
    {
        while(head<tail)
        {
            int u=q[head];
            if((x[u]-x[i])*2>t){
                mi=min(mi,dp[u+1]+x[u]*2+x[u+1]);
                head++;
            }
            else break;
        }
        //printf("%d %lld %lld %lld %d %dss\n",i,dp[q[head]]+x[q[head]+1]-x[i]+t,mi-x[i]*3,dp[i+1]+t+x[i+1]-x[i],head,tail);
        dp[i]=min(mi-x[i]*3,dp[i+1]+t+x[i+1]-x[i]);
        if(head<tail)
            dp[i]=min(dp[q[head]+1]+x[q[head]+1]-x[i]+t,dp[i]);

        while(head<tail)
        {
            int u=q[tail-1];
            if(dp[u+1]+x[u+1]>=dp[i+1]+x[i+1]){
                tail--;
            }
            else break;
        }
        q[tail++]=i;
    }
    printf("%lld\n",dp[1]+x[1]);
    return 0;
}


Measured memory_bytes: 2176
from sys import stdin
from collections import defaultdict
from math import sqrt, floor
N, P = [int(_) for _ in stdin.readline().rstrip().split()]
m = int(sqrt(P)+2)
d = defaultdict(lambda: 0)

for i in range(2, m):
    if P % i == 0:
        a = 0
        while P % i == 0:
            a += 1
            P //= i
        d[i] = a
if P != 1:
    d[P]=1

ans = 1
for p, n in d.items():
    ans *= pow(p, floor(n/N))
print(ans)

Measured memory_bytes: 3444
def main():
    n, w = map(int, input().split())
    v_list = []
    w_list = []
    for i in range(n):
        _v, _w = map(int, input().split())
        v_list.append(_v)
        w_list.append(_w)

    dp = [[0] * (w+1) for _ in range(n+1)]
    for i in range(n):
        for _w in range(1, w+1):
            # 入るなら入れる
            if w_list[i] <= _w:
                dp[i+1][_w] = max(dp[i][_w], dp[i][_w - w_list[i]] + v_list[i])
            # 無理なら入れない
            else:
                dp[i+1][_w] = dp[i][_w]

    print(dp[n][w])


main()


Measured memory_bytes: 25516
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>

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

  std::vector<int> l(N);
  for (int i=0; i<N; ++i)
    scanf("%d", &l[i]);

  std::sort(l.begin(), l.end(), std::greater<int>());
  int res=0;
  for (int i=0; i<K; ++i)
    res += l[i];

  printf("%d\n", res);
  return 0;
}


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


int main(){
	int N,M;
	int C;
	cin >> N >> M >> C;
	vector<int> B(M);
	rep(i,M)cin >> B[i];
	int ans = 0;
	rep(i,N){
		ll S = 0;
		rep(j,M){
			int A; cin >> A;
			S += A*B[j];
		}
		S += C;
		if(S>0)ans++;
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
    int n; cin >> n;
    vector<int> a (n);
    int cont = 0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(a[i] != i+1) cont++;
    }
    if(cont == 0 or cont == 2) puts("YES");
    else puts("NO");
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int ans = 1;
		
		for(int i = 0; i < n - 1; i++) {
			char c1 = s.charAt(i);
			char c2 = s.charAt(i + 1);
			if(c1 != c2) {
				ans++;
				
			}
		}
		
		System.out.println(ans);
		
		
		
		

	}

}


Measured memory_bytes: 25824
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int n;
    cin >> n;
    double ans = 0;
    
    while(n--){
    double x;
    string u;
    cin >> x >> u;
    
    if(u == "BTC"){
        x *= 380000;
        ans += x;
        
    }else{
        ans += x;
    }
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n, i, count;

    scanf("%d", &n);
    count = 0;
    for(i = 1; i < n + 1; i++){
        if(i % 2 != 0){
            count++;
            
        }
    }
    i--;
    printf("%f\n", (double)count / i);
    return 0;
}

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

int main()
{
    int r;
	char s[101];
	cin >> r >> s;
	if(r % 2 == 1){
		cout << "No" << endl;
		return 0;
	}

	for(int i=0; i<r/2; i++){
		if(s[i] != s[r/2+i]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int N;
  cin >> N;
  int n = (N % 100) % 10;
  string result;
  if (n == 3) {
    result = "bon";
  } else if (n == 0 || n == 1 || n == 6 || n == 8) {
    result = "pon";
  } else {
    result = "hon";
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((LL)1e9+7) 
#define INF ((LL)1e9+7)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
using namespace std;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

LL modpow(LL x, LL b){
	LL res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

LL modinv(LL x){
	return modpow(x, MOD-2);
}

int mx[]={0, 1, 1, 1, 0, -1, -1, -1, 0}, my[]={0, 1, 0, -1, -1, -1, 0, 1, 1};

int main(){
	LL h, w, n;
	cin >> h >> w >> n;
	vector<LL> ans(10, 0);
	ans[0] = (h-2)*(w-2);
	set<PLL> s;
	REP(i, n){
		PLL d;
		cin >> d.first >> d.second;
		s.insert(d);
	}
	set<PLL> used;
	foreach(i, s){
		REP(j, 9){
			LL ny = i.first + my[j];
			LL nx = i.second + mx[j];
			if(nx<=1||nx>=w||ny<=1||ny>=h)continue;
			if(used.count(PLL(ny, nx)))continue;
			used.insert(PLL(ny, nx));
			int count = 0;
			REP(k, 9)count += s.count(PLL(ny + my[k], nx + mx[k]));
			++ans[count];
			--ans[0];
		}
	}
	foreach(i, ans)cout << i << endl;
}


Measured memory_bytes: 62720
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define mp make_pair

int N, L;

void solve()
{
	vector<int> fla;
	for(int i=1;i<=N;++i)fla.pb(L+i-1);
	ll sum = accumulate(fla.begin(),fla.end(),0LL);
	ll ans = -1, best = 1e9;
	for(int i=0;i<N;++i){
		ll cur = sum - fla[i];
		if(abs(sum-cur)<best){
			best = abs(sum-cur);
			ans = cur;
		}
	}
	cout << ans << endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> N >> L;
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>


int main(){
    int A, B;
    int coins;

    scanf("%d %d", &A, &B);

    if(A > B){
        coins = A;
        A--;
    } else {
        coins = B;
        B--;
    }

    if(A > B){
        coins += A;
    } else {
        coins += B;
    }

    printf("%d\n", coins);
    return 0;
}

Measured memory_bytes: 1680
#

import sys
input=sys.stdin.readline

def main():
    X,N=map(int,input().split())
    p=list(map(int,input().split()))
    ans=[]
    for i in range(max(X,100-X)):
        if not X+i in p:
            ans+=[X+i]
        if not X-i in p:
            ans+=[X-i]
        if len(ans)>0:
            break
    if len(ans)==0:
        print(0)
    else:
        print(min(ans))
    
if __name__=="__main__":
    main()


Measured memory_bytes: 9204
N,S = map(int,input().split())

A = list(map(int,input().split()))
MOD = 998244353
dp = [0 for _ in range(S+1)]
#i個目までの和がjの数となるのは何通りあるかdp[i][j]
dp[0] = 1
#dp = [0 if i==0 else INF for i in range(S + 1)]

for i in range(N): #i個目まで見て。
  p = [0 for _ in range(S+1)]
  p,dp = dp,p
  for j in range(S+1):
    dp[j] = (dp[j]+p[j]*2)%MOD
    if j >= A[i]:
      #print(j,A[i],p[j-A[i]])
      dp[j] += p[j-A[i]]
  #print(dp)
ans = dp[S]%MOD
print(ans)



Measured memory_bytes: 73280
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PB push_back
#define MP make_pair
#define F first
#define S second
int c[100005];
int main()
{      
    int a,b;
    cin>>a>>b;
    if((b-2*a)%2==0)
    {
        if((b-2*a)/2<=a&&(b-2*a)/2>=0)
        {
            cout<<"Yes";
        }
        else
        {
            cout<<"No";
        }
    }
    else
    {
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 3636
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;


public class Main {
	static int max=0;
	public static void main(String[] args){
		PrintWriter out = new PrintWriter(System.out);
		InputReader sc=new InputReader(System.in);
		String string=sc.next();
		if (string.equals("ABC")) {
			System.out.println("ARC");
		}else {
			System.out.println("ABC");
		}
	}
	
	static class InputReader { 
		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;
		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}
 
		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}
 
		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}
 
		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}
 
		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}
 
		public boolean hasNext() {
			skip();
			return hasNextByte();
		}
 
		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
 
		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public double nextDouble() {
			return Double.parseDouble(next());
		}
 
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}
 
		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}
 
		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


Measured memory_bytes: 32436
#include<bits/stdc++.h>
using namespace std;
#define w(t) int t;cin>>t;while(t--)
#define pb   push_back
#define mk   make_pair
#define u_s  unordered_set
#define endl "\n"
#define prDouble(x) cout<<fixed<<setprecision(10)<<x
#define ll long long int
#define ipair pair<int,int>
#define all(x) (x).begin(), (x).end()

const int mod=pow(10,9)+7;

bool compare(pair<int,int>p1,pair<int,int>p2){
    return p1.second<p2.first;
}
/*
  ll C(ll n,ll k){
  
  if(k>n)return 0;
  
  ll ans=1;

  if(k>n-k)
    k=n-k;
  for(ll i=1;i<=k;i++)
    ans*=(n-i+1),ans/=i;

  return ans;
  }
  unsigned long long fact(long long a)
  {
  unsigned long long res=1;
  for(long long i=a;i>0;i--)
    res*=i;
  return res;
  }
  unsigned long long comb(long long a,long long b)
  {
  if((a-b)<b) b=a-b;
  if(a<=19) return fact(a)/(fact(a-b)*fact(b));
  if(a==b||b==0) return 1;
  if(b==1) return a;
  return comb(a-1,b-1)+comb(a-1,b);
  }
*/

struct activity{
  ll A,B,C;
};

void solve(activity*A,int n){

     ll dp[n+1][3];
     memset(dp,0,sizeof dp);

     dp[0][0]=A[0].A;
     dp[0][1]=A[0].B;
     dp[0][2]=A[0].C;

     for(int i=1;i<n;i++){

         dp[i][0]=A[i].A+max(dp[i-1][1],dp[i-1][2]);
         dp[i][1]=A[i].B+max(dp[i-1][0],dp[i-1][2]);
         dp[i][2]=A[i].C+max(dp[i-1][0],dp[i-1][1]);
     }

     cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
}
int main(){

    ios_base::sync_with_stdio(false); 
    cin.tie(nullptr); 
    cout.tie(nullptr);
    
    int n; cin>>n;
    activity A[n]; for(int i=0;i<n;i++)
                    cin>>A[i].A>>A[i].B>>A[i].C;
    
    solve(A,n);

    return 0;  
    
}


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

int n,k;
void dec(vector<int>&v){
	if(v.back()==1){
		v.pop_back();return;
	}
	v.back()--;
	while(v.size()<n)v.push_back(k);
}
int main(){
	cin>>k>>n;
	if(k%2==0){
		cout<<k/2;
		rep(i,n-1){
			printf(" %d",k);
		}
		cout<<endl;
		return 0;
	}
	vector<int>v(n,(k+1)/2);
	rep(i,n/2){
		dec(v);
	}
	rep(i,v.size()){
		if(i)printf(" ");
		printf("%d",v[i]);
	}
	puts("");
}
//~ #include <bits/stdc++.h>
//~ #define rep(i,n)for(int i=0;i<(n);i++)
//~ using namespace std;

//~ int n,k;
//~ vector<vector<int>>vec;
//~ vector<int>v;

//~ void dfs(){
	//~ if(!v.empty())vec.push_back(v);
	//~ if(v.size()==n)return;
	//~ for(int i=1;i<=k;i++){
		//~ v.push_back(i);
		//~ dfs();
		//~ v.pop_back();
	//~ }
//~ }
//~ int main(){
	//~ cin>>k;
	//~ for(n=1;n<=7;n++){
		//~ cout<<"n="<<n<<endl;
		//~ vec.clear();
		//~ dfs();
		//~ int id=-1;
		//~ rep(i,vec.size()){
			//~ vector<int>&v=vec[i];
			//~ bool flag=(v.size()==n);
			//~ for(int i:v)cout<<i<<' ';
			//~ cout<<endl;
			//~ for(int i:v){
				//~ if(i!=(k+1)/2)flag=false;
			//~ }
			//~ if(flag)id=i;
		//~ }
		//~ vector<int>med=vec[(vec.size()+1)/2-1];
		//~ cout<<"med:"<<endl;
		//~ for(int i:med){
			//~ cout<<i<<' ';
		//~ }
		//~ cout<<endl;
		//~ cout<<"a:"<<endl;
		//~ for(int i:vec[id]){
			//~ cout<<i<<' ';
		//~ }
		//~ cout<<endl;
		//~ cout<<((vec.size()+1)/2-1)<<' '<<id<<' '<<id-((vec.size()+1)/2-1)<<endl;
		//~ cout<<endl;
	//~ }
//~ }

Measured memory_bytes: 3456
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long 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*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return 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;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

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


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

	ll A = 0;
	ll B = 0;
	vector<ll> a(N + 1), b(N + 1);
	repn(i, N) cin >> a[i];
	repn(i, N) cin >> b[i];

	repn(i, N) {
		if (a[i] > b[i]) { B += a[i] - b[i]; }
		else {
			if ((b[i] - a[i]) % 2 == 0) { A += b[i] - a[i]; }
			else { A += b[i] - a[i] + 1; B += 1; }
		}
	}

	if (A >= B * 2) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }
	system("PAUSE");
}


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

int main() {
  int n; cin >> n;
  vector<long long> a(n);
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  for(int i = 0; i < n-1; i++){
    if(a.at(i) == a.at(i+1)){
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
}


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

int main(){ 
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int c = 1;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == c) cnt++, c++;
  }
  if (cnt == 0) cout << -1 << endl;
  else cout << n - cnt << endl;
  return 0;
} 

Measured memory_bytes: 1024
fun main(args: Array<String>) {
    val (k, s) = readLine()!!.split(" ").map(String::toInt)
    var result = 0
    for (x in 0..k) {
        for (y in 0..k) {
            val z = s - x - y
            if (0 <= z && z <= k) {
                result++
            }
        }
    }
    println(result)
}


Measured memory_bytes: 37872
S = gets.chomp.chars
ans = 0
l_count = 0
r_v = 0
skip_r_v = nil
S.each do |ch|
  if ch == '<'
    l_count += 1
    r_v = 0
    skip_r_v = nil
    ans += l_count - 1
  else
    if r_v + 1 == skip_r_v
      r_v = skip_r_v + 1
    else
      r_v += 1
    end
    if l_count >= 2
      ans += l_count
      skip_r_v = l_count
      r_v = 0
    else
      ans += r_v
    end
    l_count = 0
  end
end
if S[-1] == '<'
  ans += l_count
end
puts ans

# < > > > < < > < < < < < > > > <
# 0 3 2 1 0 1 2 0 1 2 3 4 5 2 1 0 1

# < < > > > >
# 0 1 4 3 2 1

# > > < < < <
# 2 1 0 1 2 3


Measured memory_bytes: 45700
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define bit(k) (1<<(k))
#define INF 1e9

using Cost = double;
using Edge = pair<Cost,int>;

int main(void){
    int n,m,p,a,b;
    while(cin>>n>>m>>p>>a>>b, m){
        a--,b--;
        int t[8];
        vector<vector<Edge>> g(m);
        rep(i,n) cin>>t[i];
        rep(i,p){
            int x,y,z;
            cin>>x>>y>>z;
            x--,y--;
            g[x].push_back({z,y});
            g[y].push_back({z,x});
        }
        vector<vector<double>> dp(m,vector<double>(1<<n,INF));
        using P = pair<Edge, int>;// <<cost, to>, used>
        priority_queue<P,vector<P>,greater<P>> qu;
        qu.push({{dp[a][0] = 0, a},0});
        while(qu.size()){
            P pr = qu.top(); qu.pop();
            int v = pr.first.second;
            int used = pr.second;
            if(dp[v][used] < pr.first.first) continue;
            for(Edge e : g[v]){
                rep(k,n){
                    if(used & bit(k)) continue;
                    double cost = e.first;
                    int to = e.second;
                    if( dp[to][used|bit(k)] > dp[v][used] + cost/t[k]){
                        dp[to][used|bit(k)] = dp[v][used] + cost/t[k];
                        qu.push({{dp[to][used|bit(k)], to},used|bit(k)});
                    }
                }
            }
        }
        double res = INF;
        rep(mask,1<<n){
            res = min(res, dp[b][mask]);
        }
        if(res == INF){
            cout<<"Impossible"<<endl;
        }else{
            printf("%.3f\n",res);
        }
        
    }
    return 0;
}



Measured memory_bytes: 5344
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
    

    const ll MAX = 21;
    ll a[MAX][MAX] = {};
    ll b[MAX] = {};
    ll n,m,c;
    cin >> n >> m >> c;
    for (ll i=0;i<m;i++){
        cin >> b[i];
    }
    for (ll i=0;i<n;i++){
        for (ll j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
    ll ans = 0;
    for (ll i=0;i<n;i++){
        ll tmp = 0;
        for(ll j=0;j<m;j++){
            tmp += a[i][j] * b[j];
        }
        tmp += c;
        if(tmp > 0){
            ans++;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <tuple>
#include <list>
#include <deque>
#include <stack>
#include <complex>
#include <functional>
#include <regex>
#include <map>
#include <numeric>

using namespace std;

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

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

using ll = long long;
using ld = long double;
using ull = unsigned long long;

int N, H;
int A[100001], B[100001];

int solve() {
  int maxiA = 0;
  rep(i, N) maxiA = max(maxiA, A[i]);

  vector<int> goodB;
  rep(i, N) if (B[i] > maxiA) goodB.push_back(B[i]);
  sort(goodB.begin(), goodB.end(), greater<int>());

  int res = 0;
  for (int b : goodB) {
    H -= b; res++;
    if (H <= 0) return res;
  }

  res += (H + maxiA - 1) / maxiA;
  return res;
}

int main() {
  cin >> N >> H;
  rep(i, N) cin >> A[i] >> B[i];
  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 1660
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

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

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

    int a, b, c;
    cin>>a>>b>>c;
    swap(a, b);
    swap(a, c);
    cout<<a<<" "<<b<<" "<<c;
}

Measured memory_bytes: 256
a, b, c, d = gets.split.map(&:to_i)
 
x = b - a + 1
 
ya = (b / c) - (a / c)
ya += 1 if a % c == 0

yb = (b / d) - (a / d)
yb += 1 if a % d == 0

z = (b / c.lcm(d)) - (a / c.lcm(d))
z += 1 if a % c.lcm(d) == 0
 
puts x - (ya + yb - z)

Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
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;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }

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

  ll k;
  cin >> k;

  vector<ll> a;
  ll amari = k % 50;
  rep(i, 0, 50-amari) a.pb(49-amari);
  rep(i, 0, amari) a.pb(50);

  ll d = k / 50;
  rep(i, 0, 50) a[i] += d;

  cout << 50 << endl;
  rep(i, 0, 50){
    cout << a[i] << (i == 49 ? '\n' : ' ');
  }
  return 0;
}

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

using namespace std;

int const N = 2e3 + 41;
long long const INF = 1e9 * 1LL * 2e9;

long long dp[N][N];
int n, a[N], x;

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	scanf("%d %d",&n,&x);
	for(int i=0;i<n;++i){
		scanf("%d",&a[i]);
		dp[i][0] = a[i];
	}
	for(int i=0;i<n;++i){
		for(int j=1;j<n;++j){
			int id = (i-j+n)%n;
			dp[i][j] = min(dp[i][j-1], a[id] * 1LL);
		}
	}

	long long ans = INF;
	for(int i=0;i<n;++i){
		long long pans = i * 1LL * x;
		for(int j=0;j<n;++j){
			pans += dp[j][i];
		}
		ans = min(ans, pans);
	}
	printf("%lld\n",ans);


	return 0;
}

Measured memory_bytes: 32128
n, x = gets.split(" ").map(&:to_i)

nums = gets.split(" ").map(&:to_i).sort!
diffs = []
diff = nums.last
n.times do |i|
  next if nums[i+1].nil?
  diffs << nums[i+1] - nums[i]
  diff = [(nums[i] - x).abs, diff].min
end

diffs << diff
puts n == 1 ? (nums[0] - x).abs : diffs.reduce(:gcd)

Measured memory_bytes: 12784
import sys
N,M = map(int,input().split())
AB = []
s = 0
ans = 0
for i in range (0,N):
  A,B = map(int,input().split())
  AB.append([A,B])
AB.sort()

for i in range (0,N):
  if s + AB[i][1] >= M:
    ans = ans + (M - s) * AB[i][0]
    print(ans)
    sys.exit()
  s = s + AB[i][1]
  ans = ans + AB[i][0] * AB[i][1]

Measured memory_bytes: 20072
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define li          long
#define ll          long long
#define ull         unsigned long long
#define ff          first
#define ss          second
#define pii         pair<int,int>
#define pli         pair<li,li>
#define pll         pair<ll,ll>
#define pb          push_back
#define fo(i,k,n)   for(int i = k;i<n; i++)
#define ro(i,k,n)   for(int i = k; i>=n; i--)
#define tc          int t;cin>>t;while(t--)
#define all(v)      v.begin(),v.end()
#define inf         INT_MAX
#define ninf        INT_MIN
#define W(x)        cout<<x<<endl
#define WW(x,y)     cout<<x<<' '<<y<<endl;
#define in(x)       cin>>x
#define vi          vector<int>
#define vll         vector<long long>
#define vpi         vector<pair<int>>
#define vpll        vector<pair<long long>>
#define vvi         vector<vector<int>>
#define vvll        vector<vector<long long>>
#define vvpi        vector<vector<pair<int,int>>>
#define vvpll       vector<vector<pair<long long>>>
const ll mod1 = 99844353;
const ll mod2 = 1e9+7;
template <class T>
using oset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
} 

template<class T>
T power(T a,T b){
    T res = (T)1;
    while(b>0){
        if(b&1)res = res*a;
        b>>=1;
        a*=a;
    }
    return res;
}

void solve(){
    int x,y;
    cin>>x>>y;
    if((y>=2*x)&&(y-2*x)%2 == 0&&(4*x>=y)&&(4*x-y)%2 == 0)cout<<"Yes\n";
    else cout<<"No\n";
}

signed main(){
    fastio();
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3648
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int i,x,suu,cnt;
	int hen[3];
	cnt=0;
	scanf("%d",&suu);
	while(!(suu==cnt)){
		cnt++;
		for(i=0;i<3;i++){
			scanf("%d",&hen[i]);
		}
		sort(hen,hen+3,greater<int>());
		if(hen[2]*hen[2]+hen[1]*hen[1]==hen[0]*hen[0]){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define loop(i,x,z) for (int i=x;i<z;i++)
int n, m, x, A[15][15], dp[5000][15], p[15], k = 1, price[5000], ans = INT_MAX;
int main()
{
	cin >> n >> m >> x;
	loop(i, 1, n + 1)
	{
		cin >> p[i];
		loop(j, 1, m + 1)
			cin >> A[i][j];
	}
	k = k << 12;
	loop(i, 0, k)
	{
		loop(j, 1, n + 1)
		{
			int l = 1 << (j - 1);
			if (i & l)
			{
				price[i] += p[j];
				loop(z, 1, m + 1)dp[i][z] += A[j][z];
			}
		}
	}
	loop(i, 1, k)
	{
		bool flag = 1;
		loop(j, 1, m + 1) if (dp[i][j] < x)flag = 0;
		if (flag)
		{
			ans = min(ans, price[i]);
		}
	}
	if (ans == INT_MAX)cout << -1;
	else cout << ans;
}

Measured memory_bytes: 3896
S = input()
first = int(S[0:2])
second = int(S[2:4])

if 1 <= first <= 12:
    if 1 <= second <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1 <= second <= 12:
        print('YYMM')
    else:
        print('NA')

Measured memory_bytes: 3060
#include <stdio.h>

int main(){
	int w,h;
	int i,j;

	while(1){
		scanf("%d %d",&h,&w);

		if(w == 0 && h == 0) break;
		
		for(i = 0;i < h;i++){
			for(j = 0;j < w;j++){
				printf("#");
			}
			printf("\n");
		}

		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 1836
#include <iostream>
using namespace std;
#include<math.h>
int main()
{
    int n;
    int a[100];
    int i,j,k,t=0;
    cin>>n;
    for(i=3; i<55555; i++)
    {
        k=sqrt(i);
        for(j=2; j<=k+1; j++)
        {
            if(i%j==0)
                break;
            if(j>k&&i%10==1)
            {
                a[t]=i;
                t++;
                break;
            }

        }
        if(t>n)
            break;
    }
    cout<<a[0];
    for(i=1; i<n; i++)
        cout<<" "<<a[i];
        cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> 
#include <iomanip>
#include <unordered_map>
#include <memory.h>
#include <cstring>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <cassert>
#include <atcoder/dsu>

using namespace std;
using namespace atcoder;

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

	int n, q;

	cin >> n >> q;
	dsu uf(n + 1);
	for (int i = 0; i < q; i++)
	{
		int t, u, v;
		cin >> t >> u >> v;
		if (t == 0)
		{
			uf.merge(u, v);
		}
		else
		{
			cout << uf.same(u, v) << '\n';
		}
	}
	return 0;
}

Measured memory_bytes: 3940
from collections import deque
n = int(input())
s = input()
q = deque()
r = ""
l = ""
for i in s:
    if i == ")":
        if not q:
            r+="("
        else:
            q.pop()
    else:
        q.append("(")
while q:
    q.pop()
    l+=")"
print(r+s+l)


Measured memory_bytes: 40436
#include <iostream>

using namespace std;

int main(void)
{
    unsigned int height;
    unsigned int width;
    
    while(height | width) {
        cin >> height >> width;
        if(height | width) {
            for(int i = 0; i < height; ++i) {
                if(i % 2 == 0) {
                    for(int j = 0; j < width; ++j) {
                        if(j % 2 == 0) {
                            cout << '#' << flush;
                        } else {
                            cout << '.' << flush;
                        }
                    }
                    cout << endl;
                } else {
                    for(int j = 0; j < width; ++j) {
                        if(j % 2 == 0) {
                            cout << '.' << flush;
                        } else {
                            cout << '#' << flush;
                        }
                    }
                    cout << endl;
                }
            }
            cout << endl;
        }
    }
    
    return 0;
}


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

ll dp[3001][3001];
int main(void){
    string s, t;
    cin >> s >> t;

    rep(i, s.size()){
        rep(j, t.size()){
            if(s[i] == t[j]){
                dp[i+1][j+1] = dp[i][j] + 1;
            }else{
                dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
            }
        }
    }

    string ans = "";
    ll d = dp[s.size()][t.size()];
    ll y = s.size();
    ll x = t.size();

    while(true){
        if(d == 0)break;
        if(dp[y-1][x] == d) y--;
        else if(dp[y][x-1] == d) x--;
        else{
            ans += s[y-1];
            x--;
            y--;
            d--;
        }
    }

    rep(i, ans.size()){
        cout << ans[ans.size() - i - 1];
    }
    cout << endl;

    return 0;

}


Measured memory_bytes: 70656
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int n, a, s = 0;
    cin >> n;
    a = n;
    while(n > 0)
    {
        s = s + n % 10;
        n = n / 10;
    }
    if(a % s == 0)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    char s[60] = {};
    int n, i, cnt, ans;
    int a[60] = {};
    scanf("%d%s", &n, s);
    cnt=0;
    for(i=0; i<n-2; i++){
        if(s[i]=='A'){
            a[cnt]=i;
            cnt++;
        }
    }
    ans = 0;
    for(i=0; i<cnt; i++){
        if(s[a[i]+1]=='B'&&s[a[i]+2]=='C'){
            ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}

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

int main() {
    int n,c,k,t;
    priority_queue< int, vector<int>, greater<int> > q;
    cin >> n >> c >> k;
    for (int i=0;i<n;i++) {
        cin >> t;
        q.push(t);
    }

    long long lim=-1,bn=0,bl=c;
    while (!q.empty()) {
        if (bl==0) {
            lim = q.top() + k;
            q.pop();
            bl = c - 1;
            bn += 1;
        }
        else {
            if (q.top() <= lim) {
                q.pop();
                bl -= 1;
                //if (bl==0) {bl=k;}   
            }
            else {bl = 0;}
        }
    }
    cout << bn << endl;
    return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;

int main() {
	int N, D;
	cin >> N >> D;

	int q = (D * 2) + 1;
	int ans = N / q;
	int m = N % q;

	if (m > 0) {
		ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())

li = [int(input()) for i in range(n)]
ls = sorted(li, reverse = True)

m1 = ls[0]
m2 = ls[1]
"""
for i in range(0,n):
    if(ls[i] != m1):
        m2 = ls[i]
        break
"""

for i in li:
    print(m1 if(i != m1) else m2)

Measured memory_bytes: 14160
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	set<char> st(s.begin(),s.end());
	cout<<(st.count('7')?"Yes":"No")<<endl;
	return 0;
}


Measured memory_bytes: 3660
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func next() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return int(i)
}

func chmin(a int, b int) int {
	if a > b {
		return b
	}
	return a
}

func chmax(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	scanner.Split(bufio.ScanWords)

	w := nextInt()
	h := nextInt()
	x := nextInt()
	y := nextInt()

	// max of smaller area == half size of the square
	// can be made by a line which go through both the center of the square and (x, y)
	var result float64
	result = float64(w*h) / 2.0

	// when (x, y) is exactly center of the square, there're 2 ways of getting the result above
	var result2 = 0
	if x*2 == w && y*2 == h {
		result2 = 1
	}

	/*
			if (x == 0 && y == 0) || (x == w && y == h) || (x == w && y == 0) || (x == 0 && y == h) {
				fmt.Printf("%d %d\n", 0, 0)
				return
			}

		// x axis
		var sx1, sx2, sy1, sy2, ansx, ansy, result, result2 int64
		sx1 = x * h
		sx2 = (w - x) * h
		if sx1 == 0 {
			ansx = sx2
		} else if sx2 == 0 {
			ansx = sx1
		} else {
			ansx = chmin(sx1, sx2)
		}

		// y axis
		sy1 = y * w
		sy2 = (h - y) * w
		if sy1 == 0 {
			ansy = sy2
		} else if sy2 == 0 {
			ansy = sy1
		} else {
			ansy = chmin(sy1, sy2)
		}

		result = chmax(ansx, ansy)
		result2 = 0
		if ansx == ansy {
			result2 = 1
		}
	*/

	fmt.Printf("%f %d\n", result, result2)
}


Measured memory_bytes: 640
inputs = input().rstrip()
n, a, b = [int(v) for v in inputs.split(' ')]

res = 0

for i in range(1, n + 1):
    d1 = i % 10
    d10 = (i % 100) // 10
    d100 = (i % 1000) // 100
    d1000 = (i % 10000) // 1000
    d10000 = i // 10000
    if a <= (d1 + d10 + d100 + d1000 + d10000) <= b:
        res += i

print(res)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

ll N, H;
vector<ll> a(100001, 0);
vector<ll> b(100001, 0);

int main(void){
    
    scanf("%lld %lld", &N, &H);
	for(int i = 0; i < N; ++i) scanf("%lld %lld", &a[i], &b[i]);
	sort(b.begin(), b.begin() + N, greater<ll>());
	ll amx = *max_element(a.begin(), a.begin() + N);
	
	vector<ll> v;
	ll sum = 0;
	for(int i = 0; i < N; ++i){
	    if(b[i] > amx) sum += b[i], v.push_back(sum);
	    if(sum >= H) break;
	}
	
	if(v.size()){
	    if(H - v.back() <= 0) printf("%lld\n", (ll)v.size());
	    else{
	        ll cnt = ((H - v.back()) % amx) ? ((H - v.back()) / amx) + 1 : (H - v.back()) / amx;
	        printf("%lld\n", (ll)v.size() + cnt);
	    }
	}
	else{
	    ll cnt = (H % amx) ? (H / amx) + 1 : H / amx;
	    printf("%lld\n", cnt);
	}
	
    return 0;
}


Measured memory_bytes: 2936
#include<bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int n;
    cin>>n;
    int h[n];
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    vector<int>dp(n,0);
    //dp[1]=h[1]-h[0];
    dp[1]= abs(h[1]-h[0]);
    for(int i=2;i<n;i++)
    {
        dp[i]=min(abs(h[i]-h[i-1])+dp[i-1], abs(h[i-2]-h[i])+dp[i-2]);
    }
    cout<< dp[n-1];
    return 0;
}

Measured memory_bytes: 4036
#include <iostream>
#include <array>

int main(){

	std::array<int, 4> num_a, num;

	while(std::cin >> num_a[0] >> num_a[1] >> num_a[2] >> num_a[3]){
		std::cin >> num[0] >> num[1] >> num[2] >> num[3];
		int hit = 0, blow = 0;
		for(std::size_t i = 0; i < 4; ++i){
			if(num_a[i] == num[i]){
				++hit;
			}else{
				for(std::size_t j = 0; j < 4; ++j){
					if(num_a[j] == num[i]){
						++blow;
					}
				}
			}
		}
		std::cout << hit << " " << blow << std::endl;
	}

	return 0;
}

Measured memory_bytes: 3056
#include<bits/stdc++.h>
#define maxn 100100
using namespace std;
typedef long double ldb;
typedef long long ll;
typedef pair<ldb,int> par;
struct line{ldb k,b;int operator<(const line&l)const{return k<l.k;}}l[maxn];
int n,_A[maxn],B[maxn],C[maxn];
ll sum;
ldb L,R,sx,sy,A[maxn],T[maxn];
void solve(int l,int r){
	if(l==r)return ;
	int mid=l+r>>1,ptr=l;
	solve(l,mid);
	solve(mid+1,r);
	int ql=l,qr=mid+1;
	for(;ql<=mid&&qr<=r;)
		if(A[ql]<A[qr])T[ptr++]=A[ql++],sum+=(r-qr+1);
		else T[ptr++]=A[qr++];
	for(;ql<=mid;)T[ptr++]=A[ql++];
	for(;qr<=r;)T[ptr++]=A[qr++];
	for(int i=l;i<=r;++i)A[i]=T[i];
}
ll cx(ldb mid){
	for(int i=1;i<=n;++i)
		A[i]=l[i].k*mid+l[i].b;
	sum=0,solve(1,n);
	return sum;
}
ll cy(ldb mid){
	for(int i=1;i<=n;++i)
		A[i]=(mid-l[i].b)/l[i].k;
	sum=0,solve(1,n);
	return sum;
}
int comp(line a,line b){
	return a.k>b.k;
}
int main(){
	scanf("%d",&n);
	ll z=(1ll*n*(n-1)/2+1)/2;
	for(int i=1;i<=n;++i){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		_A[i]=a,B[i]=b,C[i]=c;
		l[i].k=(ldb)-a/(ldb)b;
		l[i].b=(ldb)c/(ldb)b;
	}
	sort(l+1,l+n+1);
	L=-1e9,R=1e9;
	for(int i=1;i<=150;i++){
		ldb mid=(L+R)/2;
		if(cx(mid)>=z)R=mid;
		else L=mid;
	}
	sx=L;
	for(int i=1;i<=n;++i){
		int a=B[i],b=_A[i],c=C[i];
//		scanf("%d%d%d",&a,&b,&c);
		l[i].k=(ldb)-a/(ldb)b;
		l[i].b=(ldb)c/(ldb)b;
	}
	sort(l+1,l+n+1);
	L=-1e9,R=1e9;
	for(int i=1;i<=150;i++){
		ldb mid=(L+R)/2;
		if(cx(mid)>=z)R=mid;
		else L=mid;
	}
	sy=L;
/*	sort(l+1,l+n+1,comp);
	L=-1e9,R=1e9;
	for(int i=1;i<=150;i++){
		ldb mid=(L+R)/2;
		if(cy(mid)>=z)L=mid;
		else R=mid;
	}
	sy=L;
*/	printf("%.15lf %.15lf",(double)sx,(double)sy);
}

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

int main(){
  int N; cin >> N;
  vector<double> p(N);
  for (int i=0; i<N; i++){
    cin >> p[i];
  }
  vector<vector<double>> dp(N+1, vector<double>(N+1,0));
  dp[0][0] = 1;
  for (int i=1; i<=N; i++){
    for (int j=0; j<=N; j++){
      if (j==0) dp[i][j] = dp[i-1][j]*(1.0-p[i-1]);
      else dp[i][j] = dp[i-1][j]*(1.0-p[i-1]) + dp[i-1][j-1]*p[i-1];
    }
  }
  double ans = 0;
  for (int i=N/2+1; i<=N; i++){
    ans += dp[N][i];
  }
  cout << fixed << setprecision(10);
  cout << ans << endl;
}


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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin >> n;
  int a[n];
  map<int, int> mp;
  rep(i, n) cin >> a[i], mp[a[i]]++;
  bool flag = true;
  for(auto p : mp) {
    if(p.first == 0 && p.second != 1) flag = false;
    if(p.first != 0 && p.second != 2) flag = false;
  }
  if(!flag) {
    cout << 0 << endl;
    return 0;
  }
  int ans = 1;
  for(auto p : mp) {
    (ans *= p.second) %= mod;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4992
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX 2001
int exsearch(int*, int, int, int(*)[MAX]);
main()
{
        int i, n, q, m, *a, (*c)[MAX];
        scanf("%d", &n);
        a = (int*)malloc(sizeof(int) * n);
        c = (int(*)[2001])malloc(sizeof(int) * n * MAX);
        for(i = 0; i < n; i++){
        scanf("%d%*c", &a[i]);
        memset(c[i], -1, sizeof(c[i]));
        }
        scanf("%d", &q);
        for(i = 0; i < q; i++){
                scanf("%d%*c", &m);
                if(exsearch(a, m, n, c)){
                        printf("yes\n");
                }else{
                        printf("no\n");
                }
        }
        free(a);
        free(c);
}
int exsearch(int *a, int m, int n, int(*c)[MAX])
{
        if(!m){
        return 1;
        }else if(!n || m < 0 ){
                return 0;
        }else if(c[n- 1][m] != -1){
                return c[n-1][m];
        }else{
                c[n-1][m] = exsearch(a, m - a[n - 1], n - 1, c) ||
                        exsearch(a, m, n - 1, c);
        }
        return c[n-1][m];
}

Measured memory_bytes: 1804
#include<stdio.h>

int main(){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(0 <= a&&100 > c){
    if(a < b&&b < c){
      printf("Yes\n");
    }
    else{
      printf("No\n");
    }
  }
  return 0;
}

Measured memory_bytes: 1812
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define rep(i,n)       for(int i=0; i<n; i++)
#define clr(arr)       memset(arr, 0, sizeof arr)
#define all(x)         x.begin(), x.end()
const int MOD = 1e9 + 7;

#ifdef SMIT
template<class F, class S> ostream& operator<<(ostream &out, const pair<F, S> &p)
{
	return out << '(' << p.first << ", " << p.second << ')';
}
template<class T> auto operator<<(ostream &out, T &&x) -> decltype(x.begin(), out)
{
	out << '{';
	for (auto i = x.begin(); i != x.end(); i++)
		out << *i << (i == prev(x.end()) ? "" : ", ");
	return out << '}';
}
void dmp() {}
template<class T, class... Args> void dmp(T &&x, Args... args)
{
	cerr << x << ";  "; dmp(args...);
}
struct Nl {~Nl() {cerr << '\n';}};
#define debug(x...) cerr << (strcmp(#x, "") ? #x ":  " : ""), dmp(x), Nl(), cerr << ""
#else
#define debug(...) {}
#endif
// Yes you CAN

typedef long long ll;
//One-based indexing is used to construct this BIT
//So, ask for sum(1, n) instead of sum(0, n-1)
class BIT
{
public:
	ll n;
	vector<ll> bit;
	BIT(vector<ll> &a)
	{
		this->n = a.size();
		bit.assign(n + 1, 0);
	}
	void update(ll index, ll value)
	{
		while (index <= n)
		{
			bit[index] += value;
			index += (index) & (-index);
		}
	}
	ll sum(ll index)
	{
		//returns ans, same as sum from 1 to index
		ll ans = 0;
		while (index > 0)
		{
			ans += bit[index];
			index -= (index) & (-index);
		}
		return ans;
	}
	ll sum(ll left, ll right)
	{
		return (sum(right) - sum(left - 1));
	}
	void range_update(ll left, ll right, ll value)
	{
		//just like ordinary O(1) range update in array
		//In ordinary array, we first had to obtain difference array
		//Then, we do point updates at left and right+1
		//We then have to take prefix sum to get final range updates

		//But here in BIT, we know that sum will always stored as a prefix sum
		update(left, value);
		if (right != n)
			update(right + 1, -value);
	}

};
class Query
{
public:
	int l, r, idx;
};
const int N = 5e5 + 5;

bool com(Query& q1, Query& q2)
{
	return q1.r < q2.r;
}
int n, q;
void solve()
{
// #define TEST
	cin >> n >> q;
	vector<int> a(n + 1);
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	vector<Query> qr(q);
	rep(i, q)
	{
		cin >> qr[i].l >> qr[i].r;
		qr[i].idx = i;
	}
	sort(all(qr), com);
	BIT bit(a);
	int last[N], ans[q], qp = 0;
	memset(last, -1, sizeof last);

	// debug(qr);
	// rep(i, n) cout << qr[i].r << ' ';
	// cout << endl;
	for (int i = 1; i <= n; i++)
	{
		if (last[a[i]] != -1)
			bit.update(last[a[i]], -1);
		last[a[i]] = i;
		bit.update(i, 1);
		while (qp < q and qr[qp].r == i)
		{
			debug(qp);
			ans[qr[qp].idx] = bit.sum(qr[qp].l, qr[qp].r);
			qp++;
		}
	}
	rep(i, q)cout << ans[i] << endl;


}

int32_t main()
{
#ifdef SMIT
	// freopen("/home/smit/Desktop/in.txt", "r", stdin);
#endif
	ios_base::sync_with_stdio(false); cin.tie(nullptr);

	int t = 1;
#ifdef TEST
	cin >> t;
#endif
	while (t--)
		solve();
}

Measured memory_bytes: 31116
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <sstream>
#include <random>
#include <queue>
#include <stack>
#include <limits>
#include <cmath>
#include <numeric>
#include <algorithm>

int main(int argc, char* argv[]) {
	// 入力
	int n;
	std::cin >> n;
	std::vector<int> x(n);
	for(auto itr = x.begin(); itr != x.end(); ++itr) {
		std::cin >> *itr;
	}

	int max = *std::max_element(x.begin(), x.end());
	int min = *std::min_element(x.begin(), x.end());

	// 出力
	std::cout << max-min << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
#define REP(i, a, b) for(int i = a; i < b; i++)
typedef long long LL;
LL gcd(LL a, LL b) { return !b ? a : gcd(b, a%b); }

struct Frac {
	LL x, y;
	Frac() {}
	Frac(LL x, LL y): x(x), y(y) {
		LL g = gcd(x, y);
		this->x /= g; this->y /= g;
	}

	bool operator < (const Frac& t) const {
		return x * t.y < t.x * y;
	}

	bool operator == (const Frac& t) const {
		return x == t.x && y == t.y;
	}

	void print() { printf("%.10Lf\n", (long double)x / y); }
};

const int maxn = 55;

map<LL, int> cnt;
int n, a, b;
LL v[maxn], sum[maxn];
Frac c[maxn];

LL C(int n, int k) {
	if(n < k) for(;;);
	LL ans = 1;
	for(int i = 1; i <= k; i++) {
		ans *= n - i + 1;
		ans /= i;
	}
	return ans;
}

int main() {
	scanf("%d%d%d", &n, &a, &b);
	REP(i, 1, n + 1) { cin >> v[i]; cnt[v[i]]++; }
	sort(v + 1, v + n + 1);
	REP(i, 1, n + 1) sum[i] = v[i] + sum[i - 1];

	REP(i, a, b + 1) c[i] = Frac(sum[n] - sum[n - i], i);
	Frac ans = c[a];
	REP(i, a + 1, b + 1) if(ans < c[i]) ans = c[i];

	LL tot = 0;
	REP(i, a, b + 1) if(c[i] == ans) {
		int s = n - i + 1, t;
		for(t = s; t < n && v[s] == v[t + 1]; t++);
		tot += C(cnt[v[s]], t - s + 1);
	}

	ans.print();
	cout << tot << endl;

	return 0;
}

Measured memory_bytes: 256