akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main()
{
    int n;
    scanf("%d", &n);
    if (n < 1000) printf("ABC\n");
    else printf("ABD\n");
    return 0;
}


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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

//桁数
ll GetDigit(ll num)
{
  return log10(num) + 1;
}

//約数全列挙
vector<ll> enum_div(ll n)
{
  vector<ll> ret;
  for (ll i = 1; i * i <= n; ++i)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
      {
        ret.push_back(n / i);
      }
    }
  }
  sort(begin(ret), end(ret));
  return ret;
}

//累乗(xのn乗%mod)
ll modpow(ll x, ll n, ll mod = MAX)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

//階乗
ll factorial(ll n)
{
  if (n > 0)
    return n * factorial(n - 1);
  else
    return 1;
}

ll modinv(ll a, ll mod)
{
  ll b = mod, u = 1, v = 0;
  while (b)
  {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= mod;
  if (u < 0)
    u += mod;
  return u;
}

void Main()
{
  ll n; cin >> n;
  vll l(n); rep(i, n) cin >> l[i];
  sort(all(l));
  ll ans = 0;
  ll flag = l.size();
  reverse(all(l));
  for(ll i = 0;i < n - 2;i++)
  {
    for(ll j = i + 1;j < n - 1;j++)
    {
      for(ll k = j + 1;k < flag;k++)
      {
        if(l[k] + l[j] > l[i])
        {
          ans++;
        }
        else
        {
          break;
        }
      }
    }
  }
  fin(ans);
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
const ll INF = 1e18;
 
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll int N, K,i, S;
    cin>>N>>K>>S;
   
      for(i=0;i<N;i++)
      {
         if (i>=K)
         {
            if(S==1e9) 
              cout<<1<<' ';
            else 
              cout<<S+1<<' ';
         }
         else
         {
            cout<<S<<' ';
         }
      }
cout << endl;
}

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

#define ll long long
#define ull unsigned long long
#define inf 0x3f3f3f3f
#define met(a, x) memset(a,x,sizeof(a))
#define mp make_pair;

using namespace std;
const int mod = 19e+7;
const int N = 1e5 + 10;
const int M = 1e6 + 10;

int x[N],w[N],n,l,t;
ll c;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>l>>t;
    for(int i=1;i<=n;i++){
        cin>>x[i]>>w[i];
        if(w[i]==2)
            w[i]=-1;
    }
    for(int i=1;i<=n;i++){
        int ans=x[i]+w[i]*t;
        if(ans>0){
            c=(c+ans/l)%n;
        }
        else if(ans<0){
            c=(c+(ans+1)/l-1)%n;
        }
        x[i]=((ans%l)+l)%l;
    }
    sort(x+1,x+1+n);
    c=(c+n)%n;
    for(int i=c+1;i<=n;i++)
        cout<<x[i]<<endl;
    for(int i=1;i<=c;i++)
        cout<<x[i]<<endl;
    return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <math.h>
#include <map>
#include <deque>
#include <queue>
#include <climits>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(v) sort(v.begin(), v.end())
#define SORTFUNC(v, func) sort(v.begin(), v.end(), func)
#define PRINT(v) REP(i, v.size()) printf("%d ", v[i]); cout << endl
#define IN(n) scanf("%d", &(n))

int main(){
  int n, c, k;
  IN(n); IN(c); IN(k);
  vector<int> tab(n);
  REP(i, n) IN(tab[i]);
  SORT(tab);

  int res = 0, people = 0, starttime = tab[0];
  REP(i, n){
    if (people == c){
      res++;
      people = 1;
      starttime = tab[i];
    }
    else {
      if(tab[i] > starttime+k){
        res++;
        people = 1;
        starttime = tab[i];
      }
      else people++;
    }
    //printf("people = %d, res = %d, startime = %d\n", people, res, starttime);
  }
  if(people > 0) res++;
  printf("%d\n", res);
  return 0;
}
























// I'd like to scroll past the end of document using Atom but I seemigly have to use these blank lines instead


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

#define null               ""
#define all(dat)           dat.begin(), dat.end()
#define over(msg)          cout << msg << endl, exit(0);
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fr, to)    for (int i = fr; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

int n;
num ans, dat[100005];

bool cmp(num a, num b) {
    return a > b;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin >> n;
    loop (i, n) {
        num a, b;
        cin >> a >> b;
        ans -= b;
        dat[i] = a + b;
    }
    sort(dat, dat + n, cmp);
    for (int i = 0; i < n; i += 2) {
        ans += dat[i];
    }
    cout << ans << endl;
}


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

int main(){
 int r,c;
 cin >> r >> c;
 int table[r+1][c+1]={};

 for(int i=0;i<r;++i){
  for(int j=0;j<c;++j){
   cin >> table[i][j];
  }
 }

 for(int i=0;i<r;++i){
  int sum=0;
  for(int j=0;j<c;++j){
   sum+=table[i][j];
   cout << table[i][j] << " ";
  }
  cout << sum << endl;
 }

 int sum2=0;
 for(int j=0;j<c;++j){
  int sum1=0;
  for(int i=0;i<r;++i){
   sum1+=table[i][j];
  }
  cout << sum1 << " ";
  sum2+=sum1;
 }
 cout << sum2 << endl;

 return 0;
}

Measured memory_bytes: 3036
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include <cstddef>
using namespace std;

int main()
{
    int N, f = 0, max = 0; 
    cin >> N;
    vector<int> H(N);
    for(int i = 0; i < N; i++)
    {
        cin >> H.at(i);
        if(i > 0 && H.at(i)>H.at(i-1) && f <= max) f = 0;
        else if(i > 0 && H.at(i)>H.at(i-1) && f > max)
        {
            max = f;
            f = 0;
        }
        else if(i > 0 && H.at(i)<=H.at(i-1)) f++;
    }
    if(f > max) max = f;
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

const int mod=1e9+7;

int main(){
    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;
    if(b-a>k||c-a>k||d-a>k||e-a>k||c-b>k||d-b>k||e-b>k||d-c>k||e-c>k||e-d>k){
        cout << ":(" << endl;
    }else{
        cout << "Yay!" << endl;
    }
    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
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 countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) { 
        os << v[i]; 
        if (i != (int)v.size() - 1) 
            os << " "; 
    } 
    return os; 
} 

ll nCrModp(ll n, ll r, ll p)
{
    ll C[r+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, r); j > 0; j--)
            C[j] = (C[j] + C[j-1])%p;
    }
    return C[r];
}

int main()
{
    char c;
    cin >> c;
    print(++c);
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
lis = [0 for _ in range(10**5)]
for i in range(N):
    a, b = map(int, input().split())
    lis[a-1] += b
for j in range(10**5):
    K -= lis[j]
    if K <= 0:
        print(j+1)
        exit()

Measured memory_bytes: 5904
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var t = Console.ReadLine();

            int max = t.Length;
            for(var i=0;i<=s.Length-t.Length;i++){
                int val=0;
                for(var j=0;j<t.Length;j++){
                    if(s[i+j] == t[j]) val++;
                }
                if(t.Length - val < max) max = t.Length - val;
            }

            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 25964
s=j=0
a=[];b=[];d=[]
for i,x in enumerate(input()):
    if x=='\\':
        a+=[i]
    elif x=='/' and a:
        j=a.pop()
        c=i-j;s+=c
        while b and b[-1]>j:
            c+=d.pop();b.pop()
        b+=[j];d+=[c]
print(s)
print(len(b),*(d))

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

ll ans=0;
int n;
string s;
void dfs(int l, int r, int sum){
    if(r==n-1){
        ans+=sum+stoll(s.substr(l,n-l));
        return;
    }
    dfs(l,r+1,sum);
    dfs(r+1,r+1,sum+stoll(s.substr(l,r-l+1)));
}
int main(){
    cin>>s;
    n = s.size();
    dfs(0,0,0);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INF             1e14
#define dd              double
#define MOD             1000000007
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define nl              cout<<endl
#define fill(a,val)     memset(a,val,sizeof(a))
#define mp              make_pair
#define endl            "\n"
#define pb              push_back
#define ff              first    
#define ss              second
#define SIZE            200005
#define all(v)          v.begin(),v.end()
#define s(ar,n)         sort(ar,ar+n)
#define rs(ar,n)        sort(ar, ar+n, greater<ll>()) 
#define oa(a,n)         for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n)         for(ll i=0;i<n;i++)cin>>a[i];
#define maxa(ar,N)      *max_element(ar,ar+N)
#define mina(ar,N)      *min_element(ar,ar+N)
#define fastio()        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define printclock      cerr<<"Time : "<<1000*(long double)clock()/(long double)CLOCKS_PER_SEC<<"ms\n";
ll power(ll x, ll y){
    ll res=1;x=x;
    while(y>0){
        if(y&1)
            res = (res*x);
        y = y>>1;
        x = (x*x);
    }
    return res;
}  
ll logtwo(ll n){
    if(n==1)
        return 0;
    return logtwo(n/2)+1;
}
signed main()
{
    fastio();  
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll N;
        cin>>N;
        cout<<fixed<<setprecision(10)<<2*M_PI*N<<endl;
    }
}

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

typedef unsigned long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;

#define INF (int)(1e9)

#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,start,end) for(int i=(start);i<=(end);i++)
#define all(n) begin(n),end(n)

#define DEBUG

int main()
{
	int n,a,b;
	cin >> n;
	if(n == 1) cout << "Hello World" << endl;
	if(n == 2)
	{
		cin >> a >> b;
		cout << a+b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <complex>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
using namespace std;
using P = complex<double>;
using L = pair<P,P>;
using Poly = vector<P>;
#define X real()
#define Y imag()
const double EPS = 1e-10, pi = acos(-1), INF = 1e9;

double dot(const P a, const P b){ return a.X*b.X+a.Y*b.Y;}
double cross(const P a, const P b){ return a.X*b.Y-a.Y*b.X;}

int ccw(P a, P b, P c){
  b -= a, c -= a;
  if(cross(b,c) > EPS) return +1;
  if(cross(b,c) < -EPS) return -1;
  if(dot(b,c) < 0) return 2;
  if(norm(b) + EPS < norm(c)) return -2;
  return 0;
}

bool is_cross(L a, L b){
  P af = a.first, as = a.second, bf = b.first, bs = b.second;
  return (ccw(af,as,bf)*ccw(af,as,bs) <= 0 and ccw(bf,bs,af)*ccw(bf,bs,as) <= 0);
}

double ps_dist(P a, L s){
  P sf = s.first, ss = s.second;
  if(dot(ss-sf,a-sf) >= 0 and dot(sf-ss,a-ss) >= 0)
    return abs(cross(sf-ss,a-ss))/abs(sf-ss);
  return min(abs(a-sf),abs(a-ss));
}

double ss_dist(L a, L b){
  if(is_cross(a,b)) return 0;
  P af = a.first, as = a.second, bf = b.first, bs = b.second;
  return min({ps_dist(af,b),ps_dist(as,b),ps_dist(bf,a),ps_dist(bs,a)});
}

double polpol_dist(Poly a, Poly b){
  int N = a.size(), M = b.size();
  double ret = INF;
  for(int i = 0; i < N; ++i){
    for(int j = 0; j < M; ++j){
      ret = min(ret,ss_dist(L(a[i],a[(i+1)%N]),L(b[j],b[(j+1)%M])));
    }
  }
  return ret;
}

int main(){
  int N, M, L;
  while(cin >> N >> M >> L, N){
    --M,--L;
    vector<Poly> S(N);
    Poly star;
    P s(0,1);
    star.push_back(s);
    for(int i = 0; i < 4; ++i){
      s *= P(cos(pi*0.8),sin(pi*0.8));
      star.push_back(s);
    }
    //for(auto c : star) cerr << c << endl;
    //return 0;
    for(int i = 0; i < N; ++i){
      double x, y, a, r;
      cin >> x >> y >> a >> r;
      P t(r*cos(a/180*pi),r*sin(a/180*pi));
      for(int j = 0; j < 5; ++j){
        S[i].push_back(t*star[j] + P(x,y));
      }
    }
    vector<vector<double>> D(N,vector<double>(N,INF));
    for(int i = 0; i < N; ++i){
      for(int j = 0; j < N; ++j){
        D[i][j] = polpol_dist(S[i],S[j]);
      }
    }
    for(int k = 0; k < N; ++k){
      for(int i = 0; i < N; ++i){
        for(int j = 0; j < N; ++j){
          D[i][j] = min(D[i][j],D[i][k]+D[k][j]);
        }
      }
    }
    printf("%.12f\n",D[M][L]);
  }
}



Measured memory_bytes: 3448
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " =", (x), " "
#define A(a, i) #a "[" #i " =", i, "] =", a[i], " "
#define TIME (chrono::steady_clock::now().time_since_epoch().count())


int main()
{
  ios_base::sync_with_stdio(0);
  string s;
  cin >> s;
  deque<char> res; for(auto i: s)res.PB(i);
  int q;
  cin >> q;
  bool reversed = 0;
  REP(i, q)
    {
    int t;
    cin >> t;
    if(t == 1)reversed ^= 1;
    else
      {
      int f;
      char c;
      cin >> f >> c;
      bool z_tylu = (f == 2) ^ reversed;
      if(z_tylu)res.PB(c);
      else res.push_front(c);
      }
    }
  if(reversed)reverse(ALL(res));
  for(auto i: res)cout << i; cout << endl;
}


Measured memory_bytes: 976
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.AbstractCollection;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

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

	static class TaskD {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int k = in.nextInt();
			final int N = (int) 1e5 + 1;
			Edge[][] edges = new Edge[10][N];
			for (int i = 0; i < N; i++) {
				for (int digit = 0; digit < 10; digit++) {
					int v = i + k * digit;
					edges[digit][i] = new Edge(v / 10, v % 10);
				}
			}
			PriorityQueue<Vertex> pq = new PriorityQueue<>();
			int[] dist = new int[N];
			Arrays.fill(dist, Integer.MAX_VALUE / 3);
			dist[k] = 0;
			pq.offer(new Vertex(k, dist[k]));
			while (!pq.isEmpty()) {
				Vertex v = pq.poll();
				if (v.d != dist[v.id]) {
					continue;
				}
				for (int digit = 0; digit < 10; digit++) {
					Edge e = edges[digit][v.id];
					int u = e.dst;
					if (dist[u] > dist[v.id] + e.len) {
						dist[u] = dist[v.id] + e.len;
						pq.offer(new Vertex(u, dist[u]));
					}
				}
			}
			int ans = Integer.MAX_VALUE;
			for (int i = 0; i < N; i++) {
				ans = Math.min(ans, dist[i] + sumDigits(i));
			}
			out.println(ans);
		}

		private int sumDigits(int n) {
			int res = 0;
			while (n > 0) {
				res += n % 10;
				n /= 10;
			}
			return res;
		}

		class Vertex implements Comparable<Vertex> {
			int id;
			int d;

			Vertex(int id, int d) {
				this.id = id;
				this.d = d;
			}

			public int compareTo(Vertex o) {
				return d - o.d;
			}

		}

		class Edge {
			int dst;
			int len;

			Edge(int dst, int len) {
				this.dst = dst;
				this.len = len;
			}

		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}



Measured memory_bytes: 85192
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=unsigned long long;
using P=pair<ll,ll>;
const ll INF=1LL<<30;
const ll LINF=1LL<<62;
const double eps=1e-5;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    ll n,X;cin>>n>>X;
    vector<ll> x(n+10),sum(n+10);
    for(int i=1;i<=n;i++){
        cin>>x[i];
        sum[i]=sum[i-1]+x[i];
    }
    ll ans=LINF;
    for(ll k=1;k<=n;k++){
        ll s=0,c=1;
        s+=(sum[n%k]-sum[0])*(n/k+c+1ULL)*(n/k+c+1ULL);
        for(ll i=n%k+k;i<=n;i+=k){
            --c;
            ll id=0;
            if(i>2*k)id=i-2*k;
            s+=(sum[i]-sum[i-k]-sum[i-k]+sum[id])*(n/k+c+1LL)*(n/k+c+1LL);
        }
        s+=(n+k)*X;
        s+=sum[n]-sum[n-k];
        ans=min(ans,s);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	const Int MOD = 1e9 + 7;
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; ++i) { cin >> a[i]; }

	vector<Int> cnt(N, 0);
	Int col = 3;
	Int ans = 1;
	for (int i = 0; i < N; ++i) {
		if (a[i] == 0) {
			(ans *= col) %= MOD;
			--col;
			++cnt[0];
			continue;
		}
		(ans *= cnt[a[i] - 1]) %= MOD;
		--cnt[a[i] - 1];
		++cnt[a[i]];
	}
	cout << ans % MOD << endl;

	return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner;
public class Main
{
  public static void main(String[] args) throws Exception
  {
	Scanner sc= new Scanner(System.in);
	 String S= sc.next();
   	 String T= sc.next();
  	  if(S.length()+1==T.length() && S.equals(T.substring(0,S.length())))
  	    System.out.println("Yes");
 	   else
 	     System.out.println("No");

}
 
  
}




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

int main() {
    int m, f, r;

    while (true) {
        cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1) { break; }

        if (m == -1 || f == -1) {
            cout << "F" << endl;
            continue;
        }
        int mf = m + f;
        if (mf >= 80) {
            cout << "A" << endl;
        } else if (mf >= 65) {
            cout << "B" << endl;
        } else if (mf >= 50) {
            cout << "C" << endl;
        } else if (mf >= 30) {
            if (r >= 50) {
                cout << "C" << endl;
            } else {
                cout << "D" << endl;
            }
        } else {
            cout << "F" << endl;
        }
    }
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

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

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
// ここに処理を記述

    int N;
    string S;

    cin >> N;
    cin >> S;

    int ans = 0;

    int i=0;
    while(i < N){
        if(S[i] == 'A'){
            if(S[i+1] == 'B'){
                if(S[i+2] == 'C'){
                    ans++;
                    i = i+2;
                }
            }
        }
        i++;
    }

    cout << ans << endl;


return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision; // int64_tは9*10^18まで

int main() {
  int64_t s, ans=0;
  cin >> s;
  int dig=log10(s)+1;
  for(int tmp=0; tmp<(1<<(dig-1)); tmp++){
    bitset<10> b(tmp);
    int64_t t=s;
    int ct=1;
    for(int i=0; i<(dig-1); i++){
      if(b[i]==0) ct++;
      else{
        ans+=(t%(int)pow(10, ct));
        t/=pow(10, ct);
        ct=1;
      }
    }
    ans+=t;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3992
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        private static void Yes() { print("Yes"); }
        private static void No() { print("No"); }
        private static void print(object obj) { Console.WriteLine(obj); }

        static void Main(string[] args)
        {
            var a = ReadInts();
            if(((a[0] * a[1]) % 2) == 0)
            {
                No();
            }
            else
            {
                Yes();
            }
        }
    }
}

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

int main() {
  string S;
  cin >> S;
  if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int h1, m1, h2, m2, k; cin >> h1 >> m1 >> h2 >> m2 >> k;
    cout << h2 * 60 + m2 - (h1 * 60 + m1) - k << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

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

int main(int argc, char* argv[]){
    int M;
    scanf("%d", &M);
    printf("%d\n", 48-M);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	int x;
	cin>>x;
	int i,j,k;
	int ans=0;
	for (i=0;i<=a;i++)
	{
		for (j=0;j<=b;j++)
		{
			for (k=0;k<=c;k++)
			{
				if ((i*500+j*100+k*50)==x)
				{
					ans++;
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <deque>
#include <queue>
#include <cstring>
#include <set>
#include <list>
#include <map>
#include <random>
#include <unordered_map>
#include <stdio.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef std::vector<int> vi;
typedef std::vector<bool> vb;
typedef std::vector<string> vs;
typedef std::vector<double> vd;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<int> > vvi;
typedef vector<vll> vvll;
typedef std::vector<std::pair<int, int> > vpi;
typedef vector<vpi> vvpi;
typedef std::pair<int, int> pi;
typedef std::pair<ll, ll> pll;
typedef std::vector<pll> vpll;

const long long mod = 1000000007;

#define all(c) (c).begin(),(c).end()
#define forn(i, a, b) for(int i = a; i < b; i++)

#define pb push_back
#define mp make_pair

int main()
{
    ll q,h,s,d,n;
    // 1 2 4 8
    cin>>q>>h>>s>>d>>n;
    n*=4;
    ll ans = 0;
    ll c8 = n/8;
    n-=c8*8;
    ans += c8 * min(min(8*q, 4*h), min(2*s, d));
    if(n%2 == 1) {
        ans += q;
        n--;
    }
    if(n%4==2) {
        n-=2;
        ans += min(2*q, h);
    }
    if(n==4) {
        ans += min(4*q, min(2*h, s));
        n = 0;
    }
    cout<<ans;
}



Measured memory_bytes: 764
/*input
1
1

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>
#include <stack>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int d, t, s;
  cin >> d >> t >> s;
  int ans = 0, sum = 0;

  while (sum + s < d) {
    sum += s;
    ans++;
  }  

  ld tt = ans + (d - sum) / (s * 1.0);
  
  cout << (tt <= t ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 3648
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

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

    int ans = accumulate(a.begin(), a.end(), 0);
    if (0 <= n - ans) {
        cout << n - ans << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3660
#include<cstdio>
#include<string>
#include<vector>
#include<sstream>
#include<deque>
#include<algorithm>
#include<queue>
#include<set>

using namespace std;

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

class S{
	public:
	S(){cont=0;}
	int col;
	int cont;
};

S ret[10001];

int main(){
	while(1){
		int now=0;
		int n;
		scanf("%d",&n);
		if(n==0)break;
		int a;
		scanf("%d",&a);
		ret[now].col=a;
		ret[now].cont=1;
		now++;
		
		for(int i=2;i<=n;i++){
			/*
			rep(j,now){
				rep(k,ret[j].cont){
					printf("[%d]",ret[j].col);
				}
			}puts("");
			*/
			
			scanf("%d",&a);
			
			if(i%2==1){
				if(ret[now-1].col==a){
					ret[now-1].cont++;
				}else{
					ret[now].col=a;
					ret[now].cont=1;
					now++;
				}
			}else{
				if(ret[now-1].col==a){
					ret[now-1].cont++;
				}else{
					if(now-2>=0){
						ret[now-2].cont+=ret[now-1].cont+1;
						now--;
					}else{
						ret[now-1].col=a;
						ret[now-1].cont++;
					}
				}
			}
		}
		/*
		rep(j,now){
			rep(k,ret[j].cont){
				printf("[%d]",ret[j].col);
			}
		}puts("");
		*/
		int ans=0;
		rep(j,now){
			rep(k,ret[j].cont){
				if(ret[j].col==0){
					ans++;
				}
			}
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 0
#include<cstdio>
#include<iostream>
#include<cmath>

using namespace std;

#define PI  3.14159265358979323846264338327950288 
int main(void){

	double a,b,C;

	cin>>a>>b>>C;

	double S=(a*b*sin(C*(PI/180)))/2;
	double L=a+b+sqrt(a*a+b*b-2*a*b*cos(C*(PI/180)));
	double h=(2*S)/a;

	printf("%.8f\n%.8f\n%.8f\n",S,L,h);

	return 0;
}

Measured memory_bytes: 1240
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            // Input
            int N = Integer.parseInt(sc.next());

            // Solve
            int count = 0;
            for (int a = 1; a < N; a++) {
                for (int b = 1; b < N; b++) {
                    if (a * b >= N) {
                        break;
                    }
                    count++;
                }
            }

            System.out.println(count);
        }
    }

}

Measured memory_bytes: 36316
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;

        static void Main(string[] args)

        {
            var s = Console.ReadLine();
            var ans = "Yes";

            for (int i = 0; i < s.Length; i++)
            {
                if ((i+1) % 2 == 1 && s[i] == 'L') ans = "No";
                if ((i+1) % 2 == 0 && s[i] == 'R') ans = "No";
            }
            Console.WriteLine(ans);


        }

       
        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }

        static public long[] Input3()
        {
            string[] data = Console.ReadLine().Split();
            long[] res = new long[data.LongLength];
            for(long i = 0; i < data.LongLength; i++)
            {
                res[i] = long.Parse(data[i]);
            }
            return res;
        }
        public static long Choose(long n, long a)
        {
            long x = 1;
            long y = 1;
            for (long i = 0; i < a; i++)
            {
                x *= n - i;
                y *= i + 1;
            }
            return x / y;
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll MOD=1e9+7;
void solve()
{
	ll n;
	cin>>n;
	string ans="";
	while(n>0)
	{
		ll val=n%26;
		if(val==0) val=26;
		n-=val;
		char c=('a'+val-1);
		ans+=c;
		n/=26;
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T=1;
	//cin>>T;
	while(T--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3656
#include <cstdio>
#include <algorithm>

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

using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> Q;

int n, m;
Q g[100000];
int p[10000];
int r[10000];

void init(){
	rep(i, n){
		p[i] = i;
		r[i] = 0;
	}
}

int find(int i){
	return p[i] == i ? i : p[i] = find(p[i]);
}

bool same(int i, int j){
	return find(i) == find(j);
}

void unite(int i, int j){
	int a = find(i);
	int b = find(j);

	if(a == b){
		return;
	}

	if(r[a] > r[b]){
		p[b] = a;
	}
	else{
		p[a] = b;
		if(r[a] == r[b]){
			++r[b];
		}
	}
}

int main(){
	scanf("%d%d", &n, &m);
	rep(i, m){
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		g[i] = Q(c, P(a, b));
	}

	sort(g, g + m);
	
	init();

	int ans = 0;
	rep(i, m){
		int a = g[i].second.first;
		int b = g[i].second.second;
		int c = g[i].first;

		if(!same(a, b)){
			unite(a, b);
			ans += c;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2280
using System;

namespace ABC066B
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();

            do
            {
                str = str.Substring(0, str.Length - 2);
            } while (!str.Substring(str.Length / 2).Equals(str.Substring(0, str.Length / 2)));

            Console.WriteLine(str.Length);
        }
    }
}


Measured memory_bytes: 11092
# coding: utf-8
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
idx = 0
cnt = 0
for i in range(N):
    if A[idx] == 2:
        print(cnt+1)
        exit()
    else:
        cnt += 1
        idx = A[idx]-1
    # print("idx", idx)
print(-1)

Measured memory_bytes: 7084
use std::io;

fn gets() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let line = gets();
    let mut it = line
        .trim()
        .split_whitespace()
        .map(|x| x.parse::<usize>().unwrap());
    let (x, y) = (it.next().unwrap(), it.next().unwrap());
    if (y >= 2 * x) & (y <= 4 * x) & ((y - 2 * x) % 2 == 0) {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2160
#include<bits/stdc++.h>
using namespace std;
int main(){
  char ch[1200];
  int i=0;
  while(1){
    scanf("%c",&ch[i]);
    if(ch[i]== '\n') break;
    i++;
  }
  for(int m=0;m<i+1;m++){
    if(islower(ch[m])) printf("%c",toupper(ch[m]));
    else printf("%c",tolower(ch[m]));
  }
  return 0;
}

      
  



Measured memory_bytes: 3112
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <time.h>

using namespace std;
typedef long long int ll;

int main()
{
	char s[5];
	scanf("%s", s);
	int n=strlen(s);
	for(int i=0; i<n-1; i++){
		if(s[i]=='A' && s[i+1]=='C'){
			printf("%s\n", "Yes");
			return 0;
		}
	}
	printf("%s\n", "No");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;

bool isPrime(ll n){
  if (n<2) return false;
  else if (n==2) return true;
  else if (n%2==0) return false;

  for(ll i=3;i*i<=n;i+=2){
    if (n%i==0) return false;
  }
  return true;
}


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

  ll N;
  cin >> N;

  while (!isPrime(N)){
    N++;
  }
  cout << N << "\n";
  return 0;
}


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


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

using namespace std;

int main()
{
	int num[3];
	
	for (int i = 0; i < 3; i++){
		cin >> num[i];
	}
	
	sort(num, num + 3);
	
	for (int i = 0; i < 2; i++){
		cout << num[i] << " " ;
	}
	cout << num[2] << endl;
	
	return (0);
}

Measured memory_bytes: 1176
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <iomanip>

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

using namespace std;

typedef long long int lli;
typedef pair<int,double> Edge;

struct Info {
    int used;
    int to;
    double cost;
    Info(int u, int t, double c) : used(u), to(t), cost(c) {}
};

bool operator>(Info a, Info b) {
    return a.cost > b.cost;
}

int main () {
    int n, m, p, a, b;
    while (cin >> n >> m >> p >> a >> b, n + m) {
        a--;
        b--;
        vector<int> t(n);
        REP (i, 0, n) cin >> t[i];
        vector<vector<Edge>> G(m);
        REP (i, 0, p) {
            int x, y, z;
            cin >> x >> y >> z;
            x--;
            y--;
            G[x].push_back(Edge(y, z));
            G[y].push_back(Edge(x, z));
        }
        int size = 1 << n;
        const double inf = 1e+30;
        priority_queue<Info, vector<Info>, greater<Info>> pq;
        vector<vector<bool>> isAccess(m, vector<bool>(size, false));
        vector<vector<double>> Cost(m, vector<double>(size, inf));
        pq.emplace(0, a, 0.0);
        REP (i, 0, size) Cost[a][i] = 0.0;

        while (pq.size()) {
            auto data = pq.top();
            pq.pop();
            if (isAccess[data.to][data.used]) continue;
            isAccess[data.to][data.used] = true;
            REP (i, 0, G[data.to].size()) {
                REP (k, 0, n) {
                    if (((data.used >> k) & 1) == 1) continue;
                    double c = G[data.to][i].second / t[k];
                    if (Cost[G[data.to][i].first][data.used + (1 << k)] > Cost[data.to][data.used] + c) {
                        Cost[G[data.to][i].first][data.used + (1 << k)] = Cost[data.to][data.used] + c;
                        pq.push(Info(data.used + (1 << k), G[data.to][i].first, Cost[G[data.to][i].first][data.used + (1 << k)]));
                    }
                }
            }
        }
        double ans = inf;
        REP (i, 0, size) {
            ans = min(ans, Cost[b][i]);
        }
        if (abs(inf - ans) < 1e-9) cout << "Impossible" << endl;
        else cout << setprecision(10) << fixed << ans << endl;
    }
    return 0;
}

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

using namespace std;
int main()
{
    int n,a,b,x;
    cin>>n>>a>>b;
    x=n*a;
    if (x<=b)
    {
        cout<<x<<endl;
    }
    else
    {
        cout<<b<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin python3
# -*- coding: utf-8 -*-

#import sys
#input = sys.stdin.readline

def main():
    N = input()
    K = int(input())
    L = len(N)
    #dp[i][j][status]   status=0 は小さいのが未確定=i文字まで同じ
    #                   status=1 は小さいことが確定
    #i桁目まで決めて、0でない桁がj個
    #初期値は1 からスタート s=0,i=0,j=0
    dp = [[[0]*2 for j in range(K+1)] for i in range(L+1)]
    dp[0][0][0] = 1
    for i in range(L):
        n = int(N[i])
        for j in range(K+1):
            for st in range(2):
                for x in range(10):
                    i_ = i+1
                    j_ = j
                    st_ = st
                    if x != 0:
                        j_ += 1
                    if j_ > K:
                        continue
                    if st_ == 0 and x > n:
                        continue
                    if st_ == 0 and x < n:
                        st_ = 1
                    dp[i_][j_][st_] += dp[i][j][st]

    print(sum(dp[L][K]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int left = a+b, right = c+d;
    if (left > right)
    {
        cout << "Left";
    }
    else if (right > left)
    {
        cout << "Right";
    }
    else
    {
        cout << "Balanced";
    }
    cout << endl;    
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define pb push_back
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
#define INF 300000000000001
#define ll_max 9000000000000000000
#define PI 3.14159265358979323846L
#define fill(a, n, x) for(int i = 0; i < n; i++) a[i] = x;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define db(args...) {string _ss = #args; replace(_ss.begin(), _ss.end(), ',' , ' '); stringstream ___s(_ss) ; debug(___s, args);}
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long int ll;
typedef long double ld;
typedef vector<pair<ll,ll> > vll;
typedef vector<int> vi;
typedef pair<ll,ll> pll;
ll mod = 1000000007;
const ll N = 300001;
const ll M = log2(N);

struct point
{
    ll x, y;
};

struct node
{
    ll t, p, d, i;
};

void debug(stringstream &s) {}
template <typename T, typename... Args>
void debug(stringstream &s, T a, Args... args)
{
    string word;
    s >> word;
    cerr << word << " = " << a << endl;
    debug(s, args...);
}

ll fast_exp(ll x, ll n)
{
    if(n == 0) return 1;
    if(n & 1) return fast_exp(x, n - 1) * x % mod;
    else
    {
        ll ans = fast_exp(x, n / 2);
        return ans * ans % mod;
    }
}

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    int _ = 1;
    //cin >> _;
    int test = 0;
    while(_--)
    {
        test++;
        ll n, m, x = 0, y = 0, k, ans = 1;
        cin >> n >> k;
        ll a[n];
        for(int i = 0; i < n; i++) cin >> a[i];
        for(int i = k; i < n; i++) {
            if(a[i - k] >= a[i])
            {
                cout << "No\n";
            }
            else cout << "Yes\n";
        }
        //cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 5208
#pragma GCC optimize "03"
#include "bits/stdc++.h"

using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

map<int, int> m;
int a[N];
 
signed main() {
    IOS;
    #ifdef LOCAL
        freopen("input.txt","r", stdin);
        freopen("output.txt","w",stdout);
    #endif
    int n;  cin >> n;
    for(int i = 1; i <= n; i++){
        int p;  cin >> p;
        a[p] = i;
    }
    m[0]++; m[n+1]++;
    int ans = 0;
    for(int i = n; i >= 1; i--){
        auto iu = m.lower_bound(a[i]);
        auto il = --iu; iu++;
        if(iu->fi != n+1){
            int x = iu->fi;
            iu++;
            ans += (a[i] - il->fi)*(iu->fi - x)*i; 
            iu--;
        }
        if(il->fi != 0){
            int x = il->fi;
            il--;
            ans += (iu->fi - a[i])*(x - il->fi)*i;
        }
        m[a[i]]++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 7296