akhauriyash/Code-Regression huggingface dataset:
<?php
$N = intval(fgets(STDIN));
$hArray = array_map("intval", explode(" ", trim(fgets(STDIN))));
 
$dp[0] = 0;
$dp[-1] = 10**10;
$hArray[-1] = 10**10;
for($i = 1; $i < $N; ++$i){
    $dp[$i] = min(
        $dp[$i-1] + abs($hArray[$i] - $hArray[$i-1]), 
        $dp[$i-2] + abs($hArray[$i] - $hArray[$i-2])
    );
}
echo $dp[$N-1];

Measured memory_bytes: 19188
from queue import LifoQueue

S = str(input())

q = LifoQueue()

ans = 0
for s in S:
    if not q.empty():
        before = q.get()
        if before != s:
            ans += 1
        else:
            q.put(before)
            q.put(s)
    else:
        q.put(s)

print(ans*2)

Measured memory_bytes: 4976
def main():
    N = int(input())
    A = list(map(int, input().split()))
    prefix = [0]
    for a in A:
        prefix.append(prefix[-1]+a)
    d = dict()
    for v in prefix:
        d[v] = d.get(v, 0) + 1
    ans = 0
    for v in d:
        ans += (d[v]-1)*d[v] // 2
    return ans

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 41108
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, A, C, D;
bool B[8];

int main(){
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> A;
		if (A >= 3200)++C;
		else B[A / 400] = true;
	}
	for (int i = 0; i < 8; ++i) {
		C += B[i];
		D += B[i];
	}
	cout << max(D, 1) << sp << C << endl;
	return 0;
}

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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
const ll INF = LLONG_MAX / 2;
const ll MOD = 1e9 + 7;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int N, M;
    cin >> N >> M;
    ll dp[1 << N];
    fill(dp, dp + (1 << N), INF);
    dp[0] = 0;
    for(int i = 0; i < M; i++) {
        ll a, b;
        cin >> a >> b;
        ll cbit = 0;
        for(int j = 0; j < b; j++) {
            int c;
            cin >> c;
            cbit |= (1 << (--c));
        }
        for(int s = (1 << N) - 1; s >= 0; s--) {
            dp[s | cbit] = min(dp[s | cbit], dp[s] + a);
        }
    }
    ll ans = dp[(1 << N) - 1] == INF ? -1 : dp[(1 << N) - 1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a) //追加//
#define pp() pop_back() //削除//
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())

signed main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int x=0;
  int ans=0;
  fo(i,n){
    if(s[i]=='I')
      x++;
    else
      x--;
    ans=max(ans,x);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
{-# LANGUAGE TupleSections #-}

import Control.Monad
import Data.Array.Unboxed
import qualified Data.ByteString.Char8 as C
import qualified Data.Map.Strict as M
import Data.Maybe

main = sol . fmap get . C.lines <$> C.getContents >>= put

get = fmap (fst . fromJust . C.readInt) . C.words

put = mapM_ print

sol ([h,w,n]:ps) = if n>0 then s:elems sm else (h-2)*(w-2):replicate 9 0
  where
  m = M.fromListWith (+) $ zip
    (concatMap (\[a,b] -> range ((a-1,b-1),(a+1,b+1))) ps)
    (repeat 1) :: M.Map (Int, Int) Int
  ks = filter (\(a,b) -> 1<a && a<h && 1<b && b<w) $ M.keys m
  sm = accumArray (+) 0 (1,9) $ (,1) . (m M.!) <$> ks :: UArray Int Int
  s = (h-2)*(w-2) - length ks


Measured memory_bytes: 214140
import math

N,K,*AF = map(int, open(0).read().split())
A = sorted(AF[:N])
F = sorted(AF[N:],reverse=True)
left = 0
right = max(A) * max(F)
while left != right:
    mid = (left+right) // 2
    temp = 0
    for i in range(N):
        temp += max(A[i]-math.floor(mid/F[i]),0)
        if temp > K:
            left = mid + 1
            break
    else:
        right = mid
print(left)

Measured memory_bytes: 127928
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#define RG register
using namespace std;
const int N=103;
int n,a[N],maxx,num[N];
template<typename I> inline void read(I &ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}
	ot=x*f;}
template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}
template<typename I>inline I mx(const I&a,const I&b){return a>b ? a : b;}
inline void endd(){printf("Impossible\n"); exit(0);}
int main()
{
	//freopen("Tree Restoring.in","r",stdin);
	//freopen(".out","w",stdout);
	read(n);
	for(int i=1;i<=n;i++) read(a[i]), maxx=mx(maxx,a[i]), num[a[i]]++;
	if(maxx&1)
	{
		for(int i=maxx-maxx/2;i<=maxx;i++) if((num[i]-=2)<0) endd();
		for(int i=maxx-maxx/2;i;i--) if(num[i]) endd();
	}
	else
	{
		num[maxx/2]--;
		for(int i=maxx/2+1;i<=maxx;i++) if((num[i]-=2)<0) endd();
		for(int i=maxx/2;i;i--) if(num[i]) endd();
	}
	printf("Possible\n");
	//fclose(stdin); fclose(stdout);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	for(int i=0;s[i];i++){
		if(s[i]=='1'){
			s[i]='9';
		}else if(s[i]=='9'){
			s[i]='1';
		}
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 764
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

function Main(input) {
  const k = parseInt(input.trim(), 10);
  let x = 7%k;
  const set = new Set();
  let i = 1;
  while(!set.has(x)) {
    if (x === 0) {
      console.log(i);
      return;
    }
    set.add(x);
    x = (x*10+7)%k;
    i++;
  }
  console.log(-1);
  return 0;
}

Measured memory_bytes: 74144
#include <bits/stdc++.h>
using namespace std;
#define rep(i, j, n) for (ll i = j; i <= n; i++)
#define per(i, j, n) for (ll i = j; i >= n; i--)
#define ll long long
#define ld long double
#define ld long double
#define ii pair<ll, ll>
#define vii vector<ii>
#define vi vector<ll>
#define adj unordered_map<ll, vii>
#define MOD 1000000007
#define PI 3.14159265359
#define db1(x) cout << #x " = " << x << endl;

void i1d(vi &v) {
  for (auto &i : v)
    cin >> i;
}

void p1d(vi &v) {
  for (auto i : v)
    cout << i << ' ';
  cout << endl;
}

ll x, y;

void solve() {
  // Code goes here
  cin >> x >> y;
  ld n = ((y - 2 * x) / 2.0);
  if (n >= 0 && n == (ll)(n) && x - n >= 0)
    cout << "Yes\n";
  else
    cout << "No\n";
}

int main() {
  ios::sync_with_stdio(false);
  solve();
}

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

int main() {
    int n;
    cin >> n;
    long long x, y, m, z;
    vector<vector<long long>> a(4, vector<long long>(n));
    for (int i = 0; i < n; i++) {
        cin >> x >> y;
        a[0][i] = x+y;
        a[1][i] = x-y;
        a[2][i] = -x+y;
        a[3][i] = -x-y;
    }
    long long ans = 0;
    for (int i =0; i < 4; i++) {
        m = *min_element(a[i].begin(), a[i].end());
        z = *max_element(a[i].begin(), a[i].end());
        ans = max(ans, z-m);
    }
    cout << ans << endl;
}


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

int main() {
  int N, M, Q; cin >> N >> M >> Q;
  vector<vector<int>> S(N+1, vector<int>(N+1));
  for (int i = 0; i < M; i++) {
    int L, R; cin >> L >> R;
    S.at(L).at(R)++;
  }
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      S.at(i).at(j) += S.at(i).at(j-1);
    }
  }
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      S.at(i).at(j) += S.at(i-1).at(j);
    }
  }
  for (int i = 0; i < Q; i++) {
    int L, R; cin >> L >> R;
    cout << S.at(R).at(R) + S.at(L-1).at(L-1) - S.at(L-1).at(R) - S.at(R).at(L-1)  << endl;
  }
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main()
{
	int h,w,x,y;
	cin >> h >> w >> x >> y;
	cout << (h-x)*(w-y) << endl;
	return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define IO std::ios::sync_with_stdio(false)
#define int unsigned long long
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)
#define INF 0x3f3f3f3f

inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
  return neg * x;
}
inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}

const int maxn = 2e5 + 10;
int n,a[maxn],k;
bool vis[maxn];
vector<int> vec;
signed main() {
  IO;
  cin >> n >> k;
  rep(i,1,n) cin >> a[i];
  mset(vis,false);
  int pos = 1;
  int tmp = 0;
  vec.clear();
  while(true){
    if(vis[pos]){
      tmp = pos;
      break;
    }
    vec.push_back(pos);
    vis[pos] = true;
    pos = a[pos];
  }
  // for(auto it : vec) cout << it << ' ';
  //   cout << '\n';
  int cnt = (int)vec.size();
  int z = 0;
  for(int i = 0 ; i < cnt ; i++){
    if(vec[i] == tmp){
      z = i;
      break;
    } 
  }
  //cout << z << '\n';
  if(k < z){
    cout << vec[k] << '\n';
  }else{
    k -= z;
    int idx = k % (cnt - z);
    cout << vec[z + idx] << '\n'; 
  }
  return 0;
}

Measured memory_bytes: 7080
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
#define MAX_V 10000
#define MAX_E 100000
#define INF 1000000000
typedef pair<int ,int > P;
struct edge {int to, cost;};
int V,E;
vector<edge> G[MAX_V];
int mincost[MAX_V];
bool used[MAX_V];
int prim(){
  int res=0;
  priority_queue<P,vector<P>,greater<P> > que;
  for(int i=0;i<V;i++){
    mincost[i]=INF;
    used[i]=false;
  }
  mincost[0]=0;
  used[0]=true;
  for(int i=0;i<G[0].size();i++){
    que.push(P(G[0][i].cost,G[0][i].to));
  }
  
  while(!que.empty()){
    P p=que.top();
    que.pop();
    int v=p.second;
    if(used[v]==true)continue;
    used[v]=true;
    res+=p.first;
    for(int i=0;i<G[v].size();i++){
       que.push(P(G[v][i].cost,G[v][i].to));
    }
  }
  return res;
}
int main(){
  cin >> V >> E ;
  for(int i=0;i<E;i++){
    int s,t,c;
    cin >> s >> t >> c;
    edge e;
    e.to=t;e.cost=c;
    G[s].push_back(e);
    e.to=s;
    G[t].push_back(e);
  }
  cout << prim() << endl;
  return 0;
}

Measured memory_bytes: 7952
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Read();
            for (int i = 0; i < s.Length; i++)
            {
                for (int i1 = i+1; i1 < s.Length; i1++)
                {
                    if (s[i] == s[i1])
                    {
                        WriteLine("no");
                        return;
                    }
                }
            }
            WriteLine("yes");
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        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); }

        //最大公約数

        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

        //文字数を数える
        public static int CountChar(string s, char c)
        {
            return s.Length - s.Replace(c.ToString(), "").Length;
        }
    }
}


Measured memory_bytes: 13140
// Daniel Grzegorzewski
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

int n, a[103];

int main() {
  init_ios();
  cin >> n;
  for (int i = 1; i <= n; ++i)
    cin >> a[i];
  int res = 1e9;
  for (int i = 1; i <= 100; ++i) {
    int tmp = 0;
    for (int j = 1; j <= n; ++j)
      tmp += abs(i-a[j])*abs(i-a[j]);
    res = min(res, tmp);
  }
  cout<<res<<"\n";
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
	public static void main(String args[]) {
 
		Scanner scanner = new Scanner(System.in);
 
		int save = 0;
 
		int x = scanner.nextInt();
		int y = scanner.nextInt();
		int z = scanner.nextInt();
 
		
		System.out.println(z + " " + x + " " + y);
 
		scanner.close();
 
	}
 
}

Measured memory_bytes: 39048
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main()
{
    string n;
    cin>>n;
   string s="ABC";
   string s1="ARC";
   if(n==s)
    cout<<s1<<endl;
   else
    cout<<s<<endl;
   



    return 0;
}





Measured memory_bytes: 3572
using namespace std;
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
#define ll long long
ll n,a,b,c,d;
map<ll,ll> F;
ll f(ll n){
	if (n==0)
		return 0;
	if (n==1)
		return d;
	if (n==2)
		return d+min(d,a);
	if (F.find(n)!=F.end())
		return F[n];
	ll a0=f(n/2)+n%2*d,a1=f(n/2+1)+(2-n%2)*d;
	ll b0=f(n/3)+n%3*d,b1=f(n/3+1)+(3-n%3)*d;
	ll c0=f(n/5)+n%5*d,c1=f(n/5+1)+(5-n%5)*d;
	ll res=min(min(a+min(a0,a1),b+min(b0,b1)),c+min(c0,c1));
	return F[n]=(n*d!=(long double)n*d?res:min(n*d,res));
}
int main(){
	int T;
	scanf("%d",&T);
	while (T--){
		scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
		F.clear();
		printf("%lld\n",f(n));
	}
	return 0;
}

Measured memory_bytes: 4456
#include<stdio.h>
 
int main(){
    int i,j,t,data[10];
     
    for(i=0;i<10;i++)
    {
        scanf("%d",&data[i]);
    }
     
    for(i = 0;i < 9;i++)
    {
        for(j = 0;j < 9 - i;j++)
        {
            if(data[j] < data[j+1])
            {
                t = data[j];
                data[j] = data[j+1];
                data[j+1] = t;
            }
        }
    }
    for(i=0;i<3;i++)
    {
        printf("%d\n",data[i]);
    }
 
    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(I,0,n){cout<<(I ? " ":"")<<A[I]x;}cout<<endl;
#define pprint(A,y,m,n) rep(J,0,m){print(A[J],y,n);}
const long mod=1e9+7;
const int size=1e5;
const long inf=1e14;
int N,M;long L;
long len[2][300][300]={};
long d[300][300],e[300][300];
void warshall_floyd(long dist[][300], int id){// O(N^3)
	rep(i,0,N)rep(j,0,N){
		if(i == j) dist[i][j] = 0;
		else if(len[id][i][j] == 0) dist[i][j] = inf;
		else dist[i][j] = len[id][i][j];
	}rep(k,0,N)rep(i,0,N)rep(j,0,N){
		if(dist[i][j] > dist[i][k] + dist[k][j]){
			dist[i][j] = dist[i][k] + dist[k][j];
		}
	}return;
}
int main(){
	cin>>N>>M>>L;
	int a,b; long c;
	rep(i,0,M){
		cin>>a>>b>>c; a--; b--;
		len[0][a][b] = c;
		len[0][b][a] = c;
	}
	warshall_floyd(d, 0);
	rep(i,0,N)rep(j,0,i){
		if(d[i][j] <= L){
			len[1][i][j] = 1;
			len[1][j][i] = 1;
		}
	}
	warshall_floyd(e, 1);
	int Q; cin>>Q;
	int s,t;
	rep(i,0,Q){
		cin>>s>>t; s--; t--;
		cout<<(e[s][t] == inf ? -1 : e[s][t] - 1)<<endl;
	}
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
	int N;
	cin >> N;
	double A, sum = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> A;
		sum += 1 / A;
	}
	cout << (1 / sum);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define DEBUG_MODE
#define endl '\n'
#ifdef DEBUG_MODE
#define DEBUG(X) debug_func(X, #X)
#define DEBUG_ENDL endl
#define DEBUG_SEPARATOR_LINE cout<<"=================\n"
#else
#define DEBUG(X) 0
#define DEBUG_ENDL 0
#define DEBUG_SEPARATOR_LINE 0
#endif
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
#define DEBUG_ENDL_S(S) ((S).size() ? "\n" : "")
template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
void debug_func_preffix(const string &s) { if(s.size()) cout << s << " = "; }
template <typename T>
void debug_func(const T &t, const string &s = "") {
    debug_func_preffix(s);
    cout << t << DEBUG_ENDL_S(s);
}
template <typename T, typename U>
void debug_func(const P<T, U> &p, const string &s = "") {
    debug_func_preffix(s);
    cout << "(";
    debug_func(p.first);
    cout << ", ";
    debug_func(p.second);
    cout << ")" << DEBUG_ENDL_S(s);
}
template <typename T>
void debug_func(const V<T> &v, const string &s = "") {
    for(ll i = 0; i < v.size(); i++) {
        string t = s + "[" + to_string(i) + "]";
        debug_func(v[i], t);
    }
}

int main() {
    ll N, M;
    cin >> N >> M;
    V<ll> mv(M);
    for(ll &e : mv) cin >> e;
    ll initl = mv[0] - 1;
    mv.push_back(N + 1);
    V<ll> dist;
    for(ll i = 0; i + 1 < mv.size(); i++) dist.push_back(mv[i + 1] - mv[i] - 1);
    sort(ALL(dist));
    DEBUG(dist);
    V<ll> dsum(M + 1);
    for(ll i = 0; i + 1 < dsum.size(); i++) dsum[i + 1] = dsum[i] + dist[i];
    DEBUG(dsum);
    ll Q;
    cin >> Q;
    for(ll QQ = 0; QQ < Q; QQ++) {
        ll L;
        cin >> L;
        ll ok = 1e9, ng = 0;
        bool suc = 0;
        while(ok - ng > 1) {
            ll mid = (ok + ng) / 2;
            auto ite = lower_bound(ALL(dist), mid);
            ll idx = distance(dist.begin(), ite);
            ll cnt = distance(ite, dist.end());
            ll rdsum = dsum[M] - dsum[idx];
            ll loss = rdsum - cnt * (mid - 1);
            DEBUG(mid);
            DEBUG(idx);
            DEBUG(cnt);
            DEBUG(rdsum);
            DEBUG(loss);
            loss += initl;
            if(loss <= L) {
                ok = mid;
                suc = true;
            } else {
                ng = mid;
            }
        }
        cout << (suc ? ok : -1) << endl;
    }
    return 0;
}



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

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for (size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

//Auther: Arin Roday
#define vec vector
#define i64 long long
#define endl '\n'
#define sz(x) (x).size()
#define times(n) for(int i = 0; i < (n); ++i)

int main(){
    i64 N;
    cin >> N;
    i64 ans = 0;
    for(i64 i = 2; i * i <= N; ++i){
        i64 cur = 0;
        while(N % i == 0){
            N /= i;
            cur++;
        }
        i64 p = 1;
        while(cur - p >= 0){
            cur -= p;
            ans++;
            p++;
        }
    }
    if(N > 1) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 3628
N, K = map(int, input().split())
mod = 10**9 + 7
count = 0
for n in range(K, N+2):
  maxSum = (n*(N + N-n+1))//2
  minSum = (n*(n-1))//2
  count += maxSum - minSum + 1
  count %= mod

print(count)

Measured memory_bytes: 9196
#include<iostream>
#include<cmath>
#include<iomanip>

using namespace std;

int main(){
  int N;
  int x[11],y[11];
  double d[11][11];
  int i,k;
  cin >> N;
  for(i=0;i<=N-1;i++)
    cin >> x[i] >> y[i];
  for(i=0;i<=N-2;i++)
    for(k=i+1;k<=N-1;k++)
      d[i][k] = sqrt((x[i]-x[k])*(x[i]-x[k])+(y[i]-y[k])*(y[i]-y[k]));
  double ans = 0;
  for(i=0;i<=N-2;i++)
    for(k=i+1;k<=N-1;k++)
     ans += d[i][k];
  ans = ans * 2 / N;
  cout << setprecision(25) << ans << endl;
}

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

using namespace std;
const long long mod=1e9+7;


long long power(ll  x, ll n){
    if(n==0)return 1;
    ll temp=power(x,n/2);
    if(n%2==0)return temp*temp;
    else return x*temp*temp;

}
ll MAX(ll a,ll b){
    return a>b?a:b;

}

ll MAX(ll a,ll b,ll c){
    return max(max(a,b),c);
}
ll MIN(ll x,ll  y){
    return x+y-max(x,y);
}
ll MIN(ll x,ll y,ll z){
    return min(min(x,y),z);

}



void swap(int* a, int* b)
{
    int t = *a;
    *a = *b;
    *b = t;
}

bool f(ll x,ll y){
    return x>y;


}







int main() {
    ll n,m;
    cin>>n>>m;
     vector<ll>dp(n+1);

    for(ll i=0;i<n+1;i++){
     dp[i]=1;
    }

    for(ll i=0;i<m;i++){
        ll t;
        cin>>t;
        dp[t]=0;

    }

    for(ll i=2;i<n+1;i++){
        if(dp[i]!=0)
         dp[i]=(dp[i-1]+dp[i-2])%mod;
    }
 //   for(ll i=0;i<n+1;i++)cout<<dp[i]<<endl;
   cout<<dp[n]%mod;


    return 0;
}

































Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n;
int t[20];
double dp[20][200001];

double calc(int a,int b){
  int c=max(a-b,b-a);
  return (double)c/(double)a;
}

int main(){
  for(int i=0;i<20;i++)
    for(int j=0;j<200001;j++)
      dp[i][j]=1e9;

  cin>>n;
  for(int i=0;i<n;i++)cin>>t[i];

  for(int j=1;j<=200000;j++)dp[0][j]=calc(t[0],j);
  
  for(int i=0;i+1<n;i++){
    for(int j=1;j<=200000;j++){
      if(dp[i][j]==1e9)continue;

      for(int k=j;k<=200000;k+=j){
	dp[i+1][k]=min(dp[i+1][k],max(dp[i][j],calc(t[i+1],k)));
      }
    }
  }

  double ans=1e9;
  for(int i=1;i<=200000;i++)
    ans=min(ans,dp[n-1][i]);

  printf("%.10f\n",ans);
  
  return 0;
}

Measured memory_bytes: 32436
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int A,B;
  cin>>A>>B;
  if(A==1&&B==1)
    puts("1000000");
  else
    cout<<(max(0,4-A)+max(0,4-B))*100000<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
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; }
// const ll INF = 1LL <<60;
// const int INF = 10000;

//最大公約数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}

long long modpow(long long res,long long a, long long n, long long mod) {
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
// ここから開始
int main(){
  string s;
  cin>>s;
  int a[26];
  string ans;
  for(int i = 0; i < 26; i++) a[i]=0;
  for(int i = 0; i < s.length(); i++){
    a[s[i]-'a']++;
  }
  if(s.length()<26){
    for(int i = 0; i < 26; i++){
      if(a[i]==0){
        ans=s+(char)(i+'a');
        break;
      }
    }
  }
  else{
    vector<char> c;
    c.push_back(s[s.length()-1]);
    bool stopflag = false;

    for(int i = s.length()-2; i >= 0&&!stopflag; i--){
      if(s[i]>s[i+1]){
        c.push_back(s[i]);
      }
      else{
        sort(c.begin(),c.end());
        for(int j = 0; j < c.size()||!stopflag; j++){
          if(c[j]>s[i]&&!stopflag){
          // cout<<s[i]<<c[j]<<endl;
            ans = s.substr(0,i) + c[j];
            stopflag = true;
          }
        }
      }
    }
    if(ans.empty()) ans="-1";
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 2e5+10 , M = 5e5+10, OO = 0x3f3f3f3f ,  MOD = 1e9+7;
const double EPS = 1e-3;
#define M_PI 3.14159265358979323846
#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define pb push_back
#define F first
#define S second
#define all(v) ((v).begin()) , ((v).end())
#define sz(v)  ((int)((v).size()))
typedef pair <int,int> pii ;
typedef vector < pii > vii ;
typedef vector < int > vi;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);



int n,x;
int a[N],b[N],c[N];
ll dp[N][4];


ll solve(int idx, int preC){ //preColour = (1 : a) -- (2 : b) -- (3 : c) -- (0 : invalid)

    if(idx == n) return 0;

    ll& ret = dp[idx][preC];
    if(~ret) return ret;

    ret = -OO;
    if(preC != 1) ret = max(ret, solve(idx+1 , 1)+a[idx]);
    if(preC != 2) ret = max(ret, solve(idx+1 , 2)+b[idx]);
    if(preC != 3) ret = max(ret, solve(idx+1 , 3)+c[idx]);

    return ret;

}



int main(){


    //ios_base::sync_with_stdio(0);
    //cin.tie(0);cout.tie(0);


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

    memset(dp, -1 , sizeof dp);
    ll ans = solve(0 , 0);
    printf("%lld\n",ans);



    return 0;
}


Measured memory_bytes: 13184
#include<bits/stdc++.h>
using namespace std;
     
#define ll long long
#define loop(i,a,n) for(ll i=a;i<n;++i)
#define revloop(i,a,b) for(ll i=a;i>=b;--i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 99999999999999
#define MOD 1000000007
 
void func()
{
    ll k;
    cin>>k;
    if(k%2==0 || k%5==0){
        cout<<-1<<"\n";
        return;
    }
    ll cnt=1,t=7 % k;
    while(cnt<=10000000){
        if(t == 0){
            cout<<cnt<<"\n";
            return;
        }
        t=((t*10) % k + 7 ) % k;
        ++cnt;
    }
    cout<<-1<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w" , stdout);
    #endif
 
    ll t=1;
    //cin>>t;
    while(t--)
    {
        func();
    }

}

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

int main() {
  int n ;
   cin >> n;
  for ( int i=1 ;  ; i++){
    if ( i*i<=n && (i+1)*(i+1)>n){
      cout << i*i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define sp ' '
#define nyan "(=^・ω・^=)"
#define mkp make_pair
#define lP pair<ll,ll>
#define iP pair<int,int>

typedef long long ll;
using namespace std;
const int mod = 1e9 + 7;

int N, A, cnt;

int main(){
	cin >> N;
	for (int i = 0; i != N; ++i) {
		cin >> A;
		if (A % 2 == 0)
			++cnt;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3088
//templates
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#include <unordered_map>
#include <map>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <sstream>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define sort_key(struct_name,key_name) [](const struct_name &x, const struct_name &y){return x.key_name < y.key_name;}
#define pb(x) push_back(x)
typedef long long ll;
const long long MOD = 1e9 + 7;
using namespace std;

//main
int main(){
    string S; cin >> S;
    int c = 0;
    rep(i,S.size()){
        if(i%2==0){
            if(S[i]=='L') c += 1; 
        }
        if(i%2==1){
            if(S[i]=='R') c += 1; 
        }
    }
    if(c==0) cout << "Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 384
package main

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

var a [999][999]byte
var t = [2][2]byte{{'R', 'Y'}, {'G', 'B'}}

func main() {
	log.SetFlags(log.Lshortfile)
	nextReader = NewScanner()
	H := nextInt()
	W := nextInt()
	d := nextInt()
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			x := (-i + j + H) / d
			y := (i + j + H) / d
			x %= 2
			y %= 2
			a[i][j] = t[x][y]
		}
	}
	for i := 0; i < H; i++ {
		fmt.Println(string(a[i][:W]))
	}
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func minmax(a, b int) (int, int) {
	if a > b {
		return b, a
	}
	return a, b
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	return p[i].b < p[i].b
}

var nextReader func() string

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


Measured memory_bytes: 1664
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill((T*)array, (T*)(array+N), val);
}
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


class A500YenCoins {
public:
	void solve(std::istream& in, std::ostream& out) {
        int k, x;
        in >> k >> x;
        if(500*k >= x) out << "Yes" << endl;
        else out << "No" << endl;
	}
};


int main() {
	A500YenCoins solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int arr[100010] = {0};
    int mini = 1e9,maxi = 0;
    for (int i = 0; i < n; i++){
        int x;
        cin >> x;
        arr[x]++;
        mini = min(mini,x);
        maxi = max(maxi,x);
    }
    if (mini+1<maxi){
        cout << "No";
        return 0;
    }
    if (mini == maxi){
        if (mini == n-1 || mini*2 <= n) cout << "Yes";
        else cout << "No";
    }
    else{
        int numcolours = maxi-arr[mini];
        if (numcolours > 0 && arr[maxi] >= 2*numcolours) cout << "Yes";
        else cout << "No";
    }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans[200][200],a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>h>>w>>n;
    rep(i,n)cin>>a[i];

    ll nowy=0,nowx=0,ok=0;
    rep(i,n){
        tmp=a[i];
        while(1){
            if(tmp==0)break;
            ans[nowy][nowx]=i+1;
            if(ok==0)nowx++;
            else nowx--;
            if(nowx==w){
                nowx=w-1;
                nowy++;
                ok=1;
            }
            else if(nowx==-1){
                nowx=0;
                nowy++;
                ok=0;
            }
            tmp--;
        }
    }
    rep(i,h){
        rep(j,w){
            if(j!=w-1)cout<<ans[i][j]<<" ";
            else Cout(ans[i][j]);
        }
    }
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using P = pair<int, int>;
using pd = pair<double, pair<int, int>>;

int n, m, p, a, b;
vector<int> t;
int memo[35][35] = {0};
double minnum[35][512];

void solve();

int main() {
  cout << fixed << setprecision(12);
  while(1) {
    cin >> n >> m >> p >> a >> b;
    if(n + m + p + a + b == 0) break;
    --a;
    --b;
    for(int i = 0; i < m; ++i)
      for(int j = 0; j < m; ++j) memo[i][j] = -1;
    for(int i = 0; i < n; ++i) {
      int x;
      cin >> x;
      t.push_back(x);
    }
    sort(t.begin(), t.end(), greater<int>());
    for(int i = 0; i < p; ++i) {
      int x, y, z;
      cin >> x >> y >> z;
      --x;
      --y;
      memo[x][y] = memo[y][x] = z;
    }
    solve();
    t.erase(t.begin(), t.end());
  }
  return 0;
}

// pd: distance,point,used
void solve() {
  double ans = 100000000;
  priority_queue<pd, vector<pd>, greater<pd>> pq;
  pd now, nextp;
  now.fi = 0;
  now.se.se = 0;
  now.se.fi = a;
  pq.push(now);
  for(int i = 0; i < m; ++i)
    for(int j = 0; j < (1 << n); ++j) {
      if(i == a)
        minnum[i][j] = 0;
      else
        minnum[i][j] = 100000000;
    }
  while(pq.size() > 0) {
    now = pq.top();
    pq.pop();
    if(now.se.se == (1 << n) - 1) continue;
    for(int i = 0; i < n; ++i) {
      // if used, continue
      if(((1 << i) & now.se.se) != 0) continue;
      for(int j = 0; j < m; ++j)
        if(j != now.se.fi && memo[now.se.fi][j] != -1) {
          nextp = now;
          nextp.fi += (double)memo[now.se.fi][j] / t[i];
          nextp.se.se += (1 << i);
          if(nextp.fi >= minnum[j][nextp.se.se]) continue;
          minnum[j][nextp.se.se] = nextp.fi;
          nextp.se.fi = j;
          if(j == b) {
            ans = min(ans, nextp.fi);
            continue;
          }
          pq.push(nextp);
        }
    }
  }
  if(ans == 100000000)
    cout << "Impossible" << endl;
  else
    cout << ans << endl;
}


Measured memory_bytes: 4728
(function(stdin) {
  var lines = stdin.trim().split('\n');
  while (1) {
    var n = Number(lines.shift().trim());
    if (n === 0) {
      break;
    }
    var table = {};
    for (var i = 0; i < n; i++) {
      var conv = lines.shift().trim().split(/\s/);
      table[conv[0]] = conv[1];
    }
    var m = Number(lines.shift().trim());
    var result = '';
    for (var j = 0; j < m; j++) {
      var value = lines.shift().trim();
      if (table[value]) {
        result += table[value];
      } else {
        result += value;
      }
    }
    console.log(result);
  }
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 24116
package main

import (
	"fmt"
	"math"
)

func main() {
	var X, Y float64
	fmt.Scan(&X, &Y)
	var a, b float64
	a = (4*X - Y) / 2
	b = (-2*X + Y) / 2
	if a >= 0 && b >= 0 && isInteger(a) && isInteger(b) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func isInteger(x float64) bool {
	return math.Floor(x) == x
}


Measured memory_bytes: 1836
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;

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

  string S, T;
  cin >> S >> T;

  bool rep[50] = {};
  bool replaced = false;
  REPR(i, S.size() - T.size()) {
    replaced = true;
    REP(j, T.size()) {
      if (S[i + j] != T[j] && S[i + j] != '?') {
        replaced = false;
      }
    }
    if (replaced) {
      rep[i] = true;
      break;
    }
  }

  bool restorable = false;
  REP(i, S.size()) {
    if (rep[i]) {
      restorable = true;
    }
  }
  if (!restorable) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }

  REP(i, S.size()) {
    if (rep[i] == true) {
      cout << T;
      i += T.size() - 1;
    } else if (S[i] == '?') {
      cout << "a";
    } else {
      cout << S[i];
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
class Dice {
  private:
    int dev[6],tmp;
  
  public:
    void setNum(int i, int num) {
      dev[i] = num;
    }
    int getNum(int i) {
      return dev[i];
    }
    void e() {
      tmp = dev[0];
      dev[0] = dev[3];
      dev[3] = dev[5];
      dev[5] = dev[2];
      dev[2] = tmp;
    }
    void n() {
      tmp = dev[0];
      dev[0] = dev[1];
      dev[1] = dev[5];
      dev[5] = dev[4];
      dev[4] = tmp;
    }
    void s() {
      tmp = dev[0];
      dev[0] = dev[4];
      dev[4] = dev[5];
      dev[5] = dev[1];
      dev[1] = tmp;
    }
    void w() {
      tmp = dev[0];
      dev[0] = dev[2];
      dev[2] = dev[5];
      dev[5] = dev[3];
      dev[3] = tmp;
    }
};
bool check(Dice dice1, Dice dice2) {
  for (int i = 0; i < 6; i++) {
    if (dice1.getNum(i) != dice2.getNum(i)) return false;
  }
  return true;

}
int main() {
  int a;
  char order;
  Dice d1,d2;
  for (int i = 0; i < 6; i++) {
    scanf("%d", &a);
    d1.setNum(i,a);
  }
  for (int i = 0; i < 6; i++) {
    scanf("%d", &a);
    d2.setNum(i,a);
  }
  for (int i = 0; i < 6; i++) {
    for (int j = 0; j < 4;j++) {
      if (check(d1,d2)) break;
      d2.w();
    }
    if (check(d1,d2)) break;
    if (i == 3)  d2.w();
    else if (i == 4) d2.s();
    d2.s();
  }
  if (check(d1,d2)) printf("Yes\n");
  else printf("No\n");
  return 0;
}



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

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

    int n;
    long long k;
    cin >> n >> k;
    vector<int> as(n);
    for (int i = 0; i < n; i++) cin >> as[i];
    sort(as.begin(), as.end());
    long long L = -1e18, R = 1e18;
    // L: L以下の数はK個未満, R: R以下の数はK個以上
    while (L < R - 1) {
        long long m = (L + R) / 2;
        long long cnt = 0;
        for (int i = 0; i < n; i++) {
            int a = as[i];
            // j = [i + 1, n)の間で、a * as[j] <= mとなるjの個数を数える
            // for (int j = i + 1; j < n; j++) {
            //     if (1LL * a * as[j] <= m) cnt++;
            // }
            if (a < 0) {
                // as[j] >= m / aとなるjの個数を数える
                // 後ろのほうがおｋ
                int l = i, r = n;
                while (l < r - 1) {
                    int mid = (l + r) / 2;
                    if (1LL * a * as[mid] <= m) {
                        r = mid;
                    } else {
                        l = mid;
                    }
                }
                cnt += n - r;
            } else if (a > 0) {
                // as[j] <= m / aとなるjの個数を数える
                // 前のほうがおｋ
                int l = i, r = n;
                while (l < r - 1) {
                    int mid = (l + r) / 2;
                    if (1LL * a * as[mid] <= m) {
                        l = mid;
                    } else {
                        r = mid;
                    }
                }
                cnt += l - i;
            } else {
                if (m >= 0) {
                    cnt += n - 1 - i;
                }
            }
        }
        if (cnt < k) {
            L = m;
        } else {
            R = m;
        }
    }
    cout << R << endl;
}


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

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	int gcd = 0, mx = 0;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		mx = max(mx, a[i]);
		gcd = __gcd(gcd, a[i]);
	}

	if(k <= mx and k % gcd == 0) {
		cout << "POSSIBLE\n";
	}
	else {
		cout << "IMPOSSIBLE\n";
	}

	return 0;
}

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

int main(){
  string a;
  cin>>a;
  if(a=="A"){
    cout<<"T"<<endl;
  }else if(a=="T"){
    cout<<"A"<<endl;
  }else if(a=="G"){
    cout<<"C"<<endl;
  }else if(a=="C"){
    cout<<"G"<<endl;
  }
  
  
 
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

long long int ans[11][331];

void solve(int d, int sum, int used) {
    ++ans[d++][sum];

    for (int i = 0; i < 10; ++i) {
        if ((used & (1 << i)) == 0) {
            solve(d, sum + i * d, used | (1 << i));
        }
    }
}

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

    int n, s;
    
    solve(0, 0, 0);

    while (std::cin >> n >> s) {
        if (s < 331) {
            std::cout << ans[n][s] << std::endl;
        }
        else {
            std::cout << 0 << std::endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1216