akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
    using namespace std;
    //#include <boost/multiprecision/cpp_int.hpp>
    //using multiInt = boost::multiprecision::cpp_int;
     
    using ll = long long int;
    using ld = long double;
    using pii = pair<int, int>;
    using pll = pair<ll, ll>;
    template <typename Q_type>
    using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;
     
    const int MOD_TYPE = 1;
    const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
    const int INF = (int)1e9;
    const ll LINF = (ll)4e18;
    const ld DINF = 1e12;
    const ld PI = acos(-1.0);
    const ld EPS = 1e-11;
     
    #define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
    #define rep(i, n) REP(i, 0, n)
    #define MP make_pair
    #define MT make_tuple
    #define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
    #define Yes(n) cout << ((n) ? "Yes" : "No") << endl
    #define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
    #define possible(n) cout << ((n) ? "possible" : "impossible") << endl
    #define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
    #define all(v) v.begin(), v.end()
    #define NP(v) next_permutation(all(v))
    #define dbg(x) cerr << #x << ":" << x << endl;
     
    vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
    vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};
     
    //nCrの偶奇
    inline int C_parity(int n, int r)
    {
      return n == (r | (n - r));
    }
     
    int main()
    {
      cin.tie(0);
      ios::sync_with_stdio(false);
      cout << setprecision(30) << setiosflags(ios::fixed);
     
      int n;
      string s;
      cin >> n >> s;
      int sum = 0;
      rep(i, n)
      {
        sum ^= (s[i] - '0') * C_parity(n - 1, i) % 2;
      }
      if (sum)
      {
        cout << 1 << endl;
        return 0;
      }
      int b[1000010];
      rep(i, n - 1)
      {
        b[i] = abs(s[i] - s[i + 1]);
        if (b[i] == 1)
        {
          cout << 0 << endl;
          return 0;
        }
        b[i] /= 2;
      }
      sum = 0;
      rep(i, n - 1)
      {
        sum ^= (b[i] - '0') * C_parity(n - 2, i) % 2;
      }
      cout << (sum ? 2 : 0) << endl;
     
      return 0;
    }

Measured memory_bytes: 5276
using System;
using System.Linq;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();

            if(n % 2 == 0){
                var i = n / 2;
                var t = string.Join("",s.Take(i));
                if(s.Equals(t + t)){
                    Console.WriteLine("Yes");
                }else{
                    Console.WriteLine("No");
                }
            }else{
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

int main() {
  int a, b;
  cin >> a >> b;
  if ((a + 1) / 2 >= b) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	bool flag=false;
	for(int i=0;i<n;i++){
		int a;
		cin >> a;
		if(a%2) flag=true;
	}
	if(flag) cout << "first" << endl;
	else cout << "second" << endl;
	return 0;
}


Measured memory_bytes: 256
n, k, q = map(int, input().split(' '))

mem = [q]*n
for i in range(q):
    a = int(input()) - 1
    mem[a] = mem[a] - 1

for i in range(n):
    if k - mem[i] > 0:
        print('Yes')
    else:
        print('No')

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  string s;
  cin>>s;
  vector<char> v;
  for(auto & ch : s) {
    v.push_back(ch);
  }
  auto itr = unique(v.begin(),v.end());
  v.erase(itr,v.end());
  cout << v.size()-1<<endl;
  return 0;
}


Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
typedef long double     ld;
typedef string          str;
#define all(x)			(x).begin(),(x).end()
#define Sort(x)			sort(all(x))
#define A               first
#define B               second
#define sep             ' '
#define endl            '\n'
#define fast_io         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int MAX1 = 3e5 + 7;

ll a, b, c, T, d, e, l, r, x, y, z, mid, cnt, flag, mod = 1e9+7, p[MAX1], num[MAX1], now[MAX1], first[MAX1];
string s, t;
stack <char> st;

int main(){
	fast_io;
	cin >> a >> s;
	for (int i = 0; i < a; ++i){
		if (st.empty())	st.push(s[i]);
		else if (s[i] != st.top())	st.push(s[i]);
	}
	cout << st.size();
    return 0;
}
/*                          now or never                         */


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

const string YES = "YES";
const string NO = "NO";

int solve(std::string S)
{
    string T;
    long long ssize = S.size();

    for (int i = ssize - 1; i > 0;)
    {
        if (S[i] == 'm' && i >= 4)
        {
            if (S.substr(i - 4, 5) == "dream")
            {
                T = "dream" + T;
                i = i - 5;
            }
            else
            {
                cout << "NO" << endl;
                return 0;
            }
        }
        else if (S[i] == 'e' && i >= 4)
        {
            if (S.substr(i - 4, 5) == "erase")
            {
                T = "erase" + T;
                i = i - 5;
            }
            else
            {
                cout << "NO" << endl;
                return 0;
            }
        }
        else if (S[i] == 'r')
        {
            if (S[i - 5] == 'e' && i >= 5)
            {
                if (S.substr(i - 5, 6) == "eraser")
                {
                    T = "eraser" + T;
                    i = i - 6;
                }
                else
                {
                    cout << "NO" << endl;
                    return 0;
                }
            }
            else if (S[i - 6] == 'd' && i >= 6)
            {
                if (S.substr(i - 6, 7) == "dreamer")
                {
                    T = "dreamer" + T;
                    i = i - 7;
                }
                else
                {
                    cout << "NO" << endl;
                    return 0;
                }
            }
            else
            {
                cout << "NO" << endl;
                return 0;
            }
        }
        else
        {
            cout << "NO" << endl;
            return 0;
        }
    }

    if (S.size() == T.size())
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }

    return 0;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;

#define out(a) cout << a << endl
#define out1(a) cout << a
#define in(a) cin >> a
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define rep(i, N) for (ll i = 0; i < (ll)N; i++)
#define rep1(i, N) for (ll i = 1; i <= (ll)N; i++)
#define repi(i, j, N) for (ll j = (ll)i + 1; j < (ll)N; j++)
#define all(v) v.begin(), v.end()

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

constexpr int inf = 1e9;
constexpr ll linf = 1e18;
constexpr ll mod = 1e9 + 7;

void solve();

int main()
{
    solve();
}

void solve()
{
    int n;
    in(n);
    priority_queue<int, vector<double>, greater<double>> q;
    rep(i, n)
    {
        double v;
        in(v);
        q.push(v);
    }
    while (q.size() > 1)
    {
        double q1 = q.top();
        q.pop();
        double q2 = q.top();
        q.pop();
        double q3 = (q1 + q2) / 2;
        q.push(q3);
    }
    cout << fixed << setprecision(5) << q.top() << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<string>
#include<cstdio>
#include<algorithm>
using namespace std;
int s[5];
int main() {
	cin>>s[1]>>s[2]>>s[3];
	sort(s+1,s+3+1);
	cout<<s[1]+s[2];
	return 0;
}

Measured memory_bytes: 256
object Main {
  import java.util.Scanner
 
  def readStrings(n: Int)(implicit sc: Scanner): Array[String] = Array.fill(n) { sc.next() }
  def readInts(n: Int)(implicit sc: Scanner): Array[Int] = Array.fill(n) { sc.nextInt() }
  def readLongs(n: Int)(implicit sc: Scanner): Array[Long] = Array.fill(n) { sc.nextLong() }
  def readLineStrings(implicit sc: Scanner): Array[String] = sc.nextLine().split(' ')
  def readLineInts(implicit sc: Scanner): Array[Int] = readLineStrings.map(_.toInt)
  def readLineLongs(implicit sc: Scanner): Array[Long] = readLineStrings.map(_.toLong)
 
  def main(args: Array[String]): Unit = solve(new Scanner(System.in))
 
  def solve(implicit sc: Scanner): Unit = {
    val Array(n, m, _X, _Y) = readLineInts
    val x = readLineInts
    val y = readLineInts
    if ((x :+ _X).max < (y :+ _Y).min) {
      println("No War")
    } else {
      println("War")
    }
  }
}

Measured memory_bytes: 27336
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n, m;
  cin >> n >> m;

  vector<int> a(m);
  map<int, int> mp;
  REP(i,m){
    cin >> a[i];
    mp[a[i]]++;
  }

  llong dp[100010] = {};
  dp[0] = 1;
  REP(i,n+1){
    if(mp.find(i) != mp.end()) continue;
    if(i-1 >= 0){
      dp[i] += dp[i-1];
      dp[i] %= MOD;
    }
    if(i-2 >= 0){
      dp[i] += dp[i-2];
      dp[i] %= MOD;
    }
  }
  cout << dp[n] % MOD << endl;
  return 0;
}



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

using namespace std;

#define REP(i,m) for(ll i=0; i<m; i++)
#define FOR(i,n,m) for(ll i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define SORT(v) sort(ALL(v))
#define pb push_back
#define ll long long int
#define P pair<ll, ll>
 
int main(){
  int n;
  cin >> n;
  ll a[100010];
  REP(i, n) cin >> a[i];
  vector<int> v;
  ll ans = 0, c = 0;
  REP(i, n){
    v.pb(abs(a[i]));
    ans += abs(a[i]);
    c += (a[i]<0);
  }
  sort(ALL(v));
  if(c%2==0) cout << ans << endl;
  else cout << ans - 2*v[0] << endl;
	return 0;
}



Measured memory_bytes: 1660
def factorize(n):
    lst = []
    tmp = n

    for i in range(2, int(n ** 0.5) + 1):
        if tmp % i == 0:
            cnt = 0
            while tmp % i == 0:
                tmp //= i
                cnt += 1
            lst.append([i, cnt])

    if tmp != 1:
        lst.append([tmp, 1])

    return lst


def main():
    n = int(input())

    lst = factorize(n)
    ans = 0

    for l in lst:
        for i in range(1, 10 ** 6 + 1):
            if i * (i + 1) // 2 > l[1]:
                ans += i - 1
                break

    print(ans)


if __name__ == "__main__":
    main()


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

const int N = 2000*2000+10;
bitset<N> memo;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int sum = 0;
    memo[0] = 1;
    for(int i = 0; i < n; ++i) {
        int val;
        cin >> val;
        sum += val;
        memo |= (memo<<val);
    }
    for(int i = (sum+1)/2;; ++i) {
        if(memo[i]) {
            cout << i;
            return 0;
        }
    }
}


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main{
	static StringBuilder sb = new StringBuilder();
	public static void main(String[] args)
	{
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			int n = Integer.parseInt(br.readLine());
			int[] A = new int[n];
			for(int i = 0; i<n ; i++)
			{
				A[i] = Integer.parseInt(br.readLine());
			}
			shellSort(A,n);
			
		}catch(IOException e){
			e.printStackTrace();
		}
	}
	public static void shellSort(int[] arr , int l)
	{
		
		int m = 1 ,cnt =0;
		int G[] = new int[15];
		G[0] = 1;
		while((G[m] = G[m-1] * 3 +1) <= l){
			m++;
		}
		sb.append(m).append('\n');
		m--;
		for(; m >= 0 ; m--){
			sb.append(G[m]);
			if(m!=0)
				sb.append(' ');
			cnt += insertionSort(arr,l,G[m]);
		}
		sb.append('\n').append(cnt).append('\n');
		
		for(m = 0 ; m < l ; m++){
			sb.append(arr[m]).append('\n');
		}
			System.out.print(sb);
	}
	public static int insertionSort(int[] a,int n , int g)
	{
		int cnt = 0;
		int v;
		for(int i = g ; i < n ; i++)
		{
			v = a[i];
			int j = i-g;
			while(j >= 0 && a[j] > v)
			{
				a[j+g] = a[j];
				a[j] = v;
				j -= g;
				cnt++;
			}
		}
		return cnt;
	}
}

Measured memory_bytes: 131052
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<deque>
#include<stack>
#include<vector>
#include<cmath>
using namespace std;
typedef long long ll;
const ll INF = 0x3f3f3f3f;
const ll mod = 1e9 + 7;
const ll maxn = 1e5 + 5;
const double PI = acos(-1);
void std_quick_io () {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main () {
    std_quick_io();
    ll n, r;
    cin >> n >> r;
    ll ans = 0;
    ll cnt = 1;
    while(n >= cnt) {
        cnt*=r;
        ans ++;
    }
    cout <<ans;
    return 0;
}

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

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> h(n + 1);
  vector<int> way(n + 1, 0);
  for (int i = 1; i < n + 1; i++) cin >> h.at(i);
  for (int i = 1; i < m + 1; i++) {
    int a, b;
    cin >> a >> b;
    way.at(a) = max(way.at(a), h.at(b));
    way.at(b) = max(way.at(b), h.at(a));
  }
  int ans = 0;
  for (int i = 1; i < n + 1; i++) {
    ans += h.at(i) > way.at(i);
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 4024
#include <stdio.h>
#include <stdlib.h>


int main()
{
	int i, I, x = 0, y, z, a;
	long long t[10000] = {0};
	char n[10000] = {"s"};
	for(I = 0 ; I < 10000 ; I++)
	{
		n[I] = 's';
	}
	while(scanf("%s", n))
	{
		if(n[0] == '0')
		{
			break;
		}
		for(i = 0 ;  ; i++)
		{
			if(n[i] == 's')
			{
				for(I = 0 ; I < 10000 ; I++)
				{
					n[I] = 's';
				}
				break;
			}
			y = n[i];
			t[x] += y;
			t[x] -= 48;
		}
		x++;
	}
	for(i = 0 ; i < x ; i++)
	{
		printf("%lld\n", t[i]+48);
	}
	return 0;
}


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

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    if (isPrime(n)) {
        cout << n - 1 << '\n';
        return 0;
    }
    ll start = ceil(sqrt(n));
    ll a, b;
    for (ll i = start; i >= 0; i--) {
        if (n % i == 0) {
            a = i;
            b = n / i;
            break;
        }
    }
    a--;
    b--;
    cout << (a + b) << '\n';
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    string O, E;
    cin >> O >> E;
    
    int l = O.size();
    for(int i=0;i<l;i++){
        cout << O.at(i);
        if(i < E.size())
            cout << E.at(i);
    }
    cout << endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,i,x,ans,sum;
map<ll,ll>mp;
int main(){
	scanf("%lld",&n);
	mp[0]++;
	for(i=1;i<=n;i++){
		scanf("%lld",&x);
		sum+=x;
		ans+=mp[sum];mp[sum]++;
	}
	printf("%lld",ans);
}

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

int main(){
  vector<int> a(3);
  for(int i=0;i<3;++i){
    cin >> a.at(i);
  }
  int num_5=0;
  int num_7=0;
  for(int i=0;i<3;++i){
    if(a.at(i)==5) num_5++;
    if(a.at(i)==7) num_7++;
  }
  if(num_5==2 && num_7==1){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1000000007;
const int INF = 1001001001;

int main(){
    
    int n; cin>>n;
    map<string,int> mp;
    string s,t;
    
    bool ok = true;
    for(int i=0; i<n; i++){
        cin>>s;
        if(mp.count(s))         ok = false;
        if(i && s[0]!=t.back()) ok = false;
        
        mp[s]++;
        t = s;
    }
    
    if(ok)cout << "Yes" << endl;
    else  cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 3652
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
newa = sorted(a)
newb = sorted(b)
ans = newa[0] + newb[0]
for i in range(M):
    x, y, c = map(int, input().split())
    ans = min(ans, a[x - 1] + b[y - 1] - c)
print(ans)


Measured memory_bytes: 18612
#include <iostream>
#include <cstdio>

int main()
{    
    int h, w;
    while (true) {
        std::cin >> h >> w;
        if (h == 0 && w == 0) {
            break;
        }

        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                std::printf("#");
            }
            std::printf("\n");
        }
        std::printf("\n");   
    }


    return 0;
}


Measured memory_bytes: 3068
n = int(input())
li = [int(input()) for _ in range(n)]
ans = 1
index = 0
if li[index] == 2:
  print(ans)
  exit()
else:
  index = li[index] - 1
  ans += 1

for i in range(1, n):
  if li[index] == 2:
    print(ans)
    exit()
  else:
    index = li[index] - 1
    ans += 1
print(-1)

Measured memory_bytes: 7084
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans = max({a*c,a*d,b*c,b*d});
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
import sys
input = sys.stdin.readline

n,Q=map(int,input().split())
b_num = 2**(n-1).bit_length()
mx = 10**9
segl=[mx]*2*b_num 

def update(k, x):
    k += b_num-1
    segl[k] = x
    while k+1:
        k = (k-1)//2
        segl[k] = min(segl[k*2+1],segl[k*2+2])
    
if __name__ == '__main__':
    xs = []
    for i in range(n):
        s,t,x=map(int,input().split())
        xs += [(s-x-0.4,True,x,i), (t-x-0.5,False,x,i)]
    for _ in range(Q):
        xs.append((int(input()),2))
    xs.sort(key=lambda x:x[0])
    for x in xs:
        if x[1]==2:
            print(segl[0] if segl[0]!= mx else -1)
            continue
        update(x[3], x[2] if x[1] else mx)


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

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    int number_of_days[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    number_of_days[a] = b;
    int res = 0;
    for (int i = 1; i <= a; i++) {
		for (int j = 1; j <= number_of_days[i]; j++) {
			res += i == j;
		}
	}
	cout << res;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,M;cin >> N >> M;
  cout << (N-1)*(M-1) << endl;
  return 0;
}


Measured memory_bytes: 256
/*input
5
138 138 138 138 138
*/

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<double> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v.at(i);
    }
    sort(v.begin(), v.end());
    double ans = v.at(0);
    for (int i = 1; i < n; i++) {
        ans = (ans+v.at(i))/2.0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
A = sorted(A)[::-1]

if N == 2:
    print(A[0])

else:
    ans = A[0]
    cnt = 1
    n = N - 2

    while(1):

        ans += A[cnt]
        n -= 1
        if n == 0:  break

        ans += A[cnt]
        n -= 1
        if n == 0:  break

        cnt += 1

    print(ans)

Measured memory_bytes: 94160
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define sz(x) int(x.size())
using ll = long long;
const ll LLINF = numeric_limits<long long>::max();
const int mod = 1000000007;
const int INF = 1001001001;

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

    int ans=0;

    if(N>=2){
        ans += N*(N-1) /2 ;
    }
    if(M>=2){
        ans +=M *(M-1) /2;
    }

    cout << ans;

    return 0;
}

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


using namespace std ;


//////////////////nao entendi por que guloso nao da certo///////////////
///////////so achar os dois adjacentes menores/////////////

vector<ll> sum;
ll dp[405][405];


ll cost(int i, int j)
{
	if(i - 1 >= 0)
	{
		return sum[j] - sum[i-1];
	}

	return sum[j];
}

ll solve(int l, int c)
{
	if(dp[l][c] >= 0)
		return dp[l][c];

	if(l == c)
		return dp[l][c] = 0LL;

	dp[l][c] = 999999999999999;
	for (int i = l; i <= c; ++i)
	{
		dp[l][c] = min(dp[l][c], solve(l, i) + solve(i+1, c) + cost(l, c));
	}

	return dp[l][c];

}


 
int main()
{
	int n;
	ll num;

	cin >> n;

	

	ll aux = 0LL;
	for (int i = 0; i < n; ++i)
	{
		cin >> num;
		aux += num;
		sum.push_back(aux);
	}
 	
 	memset(dp, -1, sizeof(dp));
 	

	cout << solve(0, n - 1) << endl;
	 
}

Measured memory_bytes: 4916
from bisect import bisect_left, bisect_right
n,q=map(int,input().split())
s=list(input())
actable=[]
for i in range(len(s)-1):
    if s[i]=="A":
        if s[i+1]=="C":
            actable.append(i+1)
for i in range(q):
    ans=0
    l,r=map(int,input().split())
    ans=bisect_left(actable,r)-bisect_left(actable,l)
    print(ans)

Measured memory_bytes: 59280
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    int sum=accumulate(a,a+k,0);
    cout<<sum;
}

Measured memory_bytes: 3572
#!/usr/bin/env python3


import heapq
import sys


def main():
    pq = []
    for line in sys.stdin:
        args = line.split()
        if args[0] == "insert":
            heapq.heappush(pq, -int(args[1]))
        elif args[0] == "extract":
            print(-heapq.heappop(pq))
        else:
            return


if __name__ == '__main__':
    main()

Measured memory_bytes: 47468
#include "bits/stdc++.h"
#define int long long
#define all(c) (c).begin(), (c).end()
#define cpresent(c,x) ((c).find(x) != (c).end()) 
#define vpresent(c,x) (find(all(c),x) != (c).end())
#define endl '\n'
#ifdef LOCAL
#include "/home/iggaboi/Desktop/CP/debug.h"
#else
#define debug(x...)
#endif
using namespace std;

int n;

void solve(){
    cin >> n;
    vector<int> ara(n);
    int negs = 0;
    int minpos = 1e9 + 69;
    bool zeroes = false;
    for(int& i : ara){
        cin >> i;
        if(i == 0)
            zeroes = true;
        if(i < 0)
            ++negs;
        minpos = min(minpos, abs(i));
    }
    int sum = 0;
    for(int i : ara)
        sum += abs(i);
    if(zeroes)
        cout << sum << endl;
    else if(negs&1^1)
        cout << sum << endl;
    else
        cout << sum - 2*minpos << endl; 
}

int32_t main(){
	ios_base::sync_with_stdio(false),cin.tie(nullptr);
	// int t; cin >> t;
	// while(t--)
		solve();
	return 0;
}


Measured memory_bytes: 4004
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=a-1;i>=b;i--)
#define endl '\n'
#define spc " "
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.14159265358979323
#define sz(a) (int)((a).size())
#define len(a) (int)(a.length())
#define FOR(i,j,k,l) for(ll i=j;i<k;i+=l)
#define CC(x) cout<<x<<endl


void Fast_IO() {
   ios::sync_with_stdio(0);
   cin.tie(0);
   #ifndef ONLINE_JUDGE
   freopen("input.in","r",stdin);
   freopen("output.out","w",stdout); 
   #endif
} 

int main(){
   //Fast_IO();
   ll a,b,c;
   cin>>a>>b>>c;
   ll index=0;
   f(i,1,10000){
      ll ans = b*i;
      if(ans>=a){
         index=i;
         break;
      }
   }
   cout<<c*index<<endl;

}





Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
using namespace std;
string s;
ll n,l,r,c,hs;
vector<ll> vv;
ll rct(ll aa)
{
	ll le=0,re=vv.size()-1,ce,hh;
	hh=re+1;
	while(le<=re)
	{
		ce=(le+re)/2;
		if(vv[ce]>=aa)
		{
			hh=ce;
			re=ce-1;
		}
		else
			le=ce+1;
	}
//	cout<<"HH"<<hh<<" "<<vv.size()<<"\n";
	return vv.size()-hh;
}
bool rmt(ll aa)
{
//	cout<<"aa"<<aa<<"\n";
	ll ii,jj;
	for(ii=0;ii<n;ii++)
	{
		ll te=rct(ii-aa+1)+(s[ii]-'0');
		if(ii+aa-1<n)
		{
			
			if(te%2==1)
			{
				vv.push_back(ii);
//				cout<<ii<<"\n";
			}
//				cout<<ii<<"d\n";
		}
		else
		{
			if(te%2==1)
			{
//				cout<<ii<<"ii\n";
//				cout<<"["<<rct(ii-aa+1)<<"]\n";
				if(ii>=aa)
					return 1;
				else
				{
					for(jj=n-1;jj>=0;jj--)
					{
						te=rct(jj-aa+1)+(s[jj]-'0');
						if(te%2==1)
						{
							if(n-jj-1>=aa)
								return 1;
							else
								return 0;
						}
					}
					return 0;
				}
			}	
		}
	}
//	cout<<"s"<<aa<<"\n";
	return 1;
}
int main()
{
	cin>>s;
	n=s.length();
	l=1;
	r=n;
	while(l<=r)
	{
		vv.clear();
		c=(l+r)/2;
		if(rmt(c))
		{
			hs=c;
			l=c+1;
		}
		else
			r=c-1;
	}
	cout<<hs<<"\n";
}

Measured memory_bytes: 768
import itertools

N=int(input())
F=[list(map(int,input().split())) for i in range(N)]
P=[list(map(int,input().split())) for i in range(N)]

bit=list(itertools.product([0,1], repeat=10))
bit.pop(0)
ans=-10**10

for i in range(1023):
    a=0
    for j in range(N):
        t=sum([F[j][k]*bit[i][k] for k in range(10)])
        a+=P[j][t]
    ans=max(a,ans)

print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;

int main() {
	int t;
    cin >> t;
    while(t--) {
        ll n, m, a, b;
        cin >> n >> m >> a >> b;
        cout << floor_sum(n, m, a, b) << endl;
    }
}


Measured memory_bytes: 3636
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		int X = sc.nextInt();
		int[] A = new int [N];

		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		for(int i = 0; i < N; i++) {
			X += (D-1)/A[i] +1;
		}
		System.out.println(X);
	}

}


Measured memory_bytes: 21844
package main

import(
    "fmt"
)



func main() {
    var n int
    fmt.Scan(&n)
    flg := false
    ans := "No"
    for{
        if n == 0{
            break
        }
        if n%10 == 9{
            flg = true
        }
        n/=10
    }
    if flg{
        ans = "Yes"
    }
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

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

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

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using P=pair<int,int>;
using ll=long long;
int main(){
  int n,m; cin>>n>>m;
  vector<P> num(m);
  for(int i=0;i<m;i++){
    int a,b; cin>>a>>b;
    num[i]=P(a,b);
  }
  ll ans=0;
  sort(num.begin(),num.end());
  for(int i=0;i<m;i++){
    int x=num[i].first,y=num[i].second;
    while(x<y && i<m){
      i++;
      int c=num[i].first,d=num[i].second;
      if(x<c) x=c;
      if(d<y) y=d;
    }i--;
    ans++;
  }
  cout<<ans<<endl;
}

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

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

int max2(int a, int b)
{
  if ( a > b ) return a;
  else return b;
}

int main()
{
  int a, b, c;
  while ( scanf("%d %d %d", &a, &b, &c) != EOF )
  {
    int least = min2( a, min2( b, c));
    int great = max2( a, max2( b, c));
    int midds = a+b+c-least-great;
    int ans = least*midds/2;
    printf("%d\n", ans);
  }
  return 0;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n,a,b;

signed main() {
    cin >> n >> a >> b;
    cout << n/(a+b)*a + min(a, n%(a+b)) << endl;
}

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    auto A = new long[][](2);
    foreach (i; 0 .. N)
        A[i & 1] ~= lread();
    A[0].sort();
    A[1].sort();
    long[2] jj;
    long ans;
    // auto S = new long[](N);
    // foreach (i; 0 .. N)
    // {
    //     S[i] = A[i & 1][jj[i & 1]++];
    // }
    // jj[] = 0;
    // writeln(S);
    // S.sort();
    // writeln(S);
    foreach (i; 0 .. N)
    {
        if (A[1].length <= jj[1] || (jj[0] < A[0].length && A[0][jj[0]] < A[1][jj[1]]))
        {
            long j = jj[0] * 2;
            ans += (i & 1) == 1;
            // writeln(j - i);
            jj[0]++;
        }
        else
        {
            long j = jj[1] * 2 + 1;
            ans += (i & 1) == 0;
            // writeln(j - i);
            jj[1]++;
        }
    }
    writeln(ans / 2);
}


Measured memory_bytes: 4860
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()
#define pb         push_back
#define mp         make_pair

template<class T> void pp(T a,int n){rep(i,n)cout<<a[i]<<' ';cout<<endl;}
typedef long long ll;
typedef vector<int> vint;

bool solve(vint r,vint c,int n){
  int cp=n-1;
  int cnt=0;
  

  while(cp >=0){
    if (c[cp] != 0)break;
    cp--;
  }

  rep(i,n){
    if (cp+1 != r[i])return false;
    cnt++;
    while(cp >=0 && c[cp]-cnt == 0){
      cp--;
    }
  }


  return true;
}

main(){
  int n;

  while(cin>>n && n){
    vector<int> r,c;
    int tmp;
    rep(i,n){
      cin>>tmp;
      r.pb(tmp);
    }

    rep(j,n){
      cin>>tmp;
      c.pb(tmp);
    }
    sort(ALL(r),greater<int>());
    sort(ALL(c),greater<int>());
    


    if (solve(r,c,r.size()))puts("Yes");
    else puts("No");
  }
}

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

int main() {
  //
  map<int, int> m;
  int n, k;
  cin >> n >> k;
  rep(i, n) {
    int a;
    cin >> a;
    if (m.find(a) == m.end()) {
      m[a] = 1;
    } else {
      m[a]++;
    }
  }
  vi cnt;
  for (auto& x : m) {
    cnt.emplace_back(x.second);
  }
  sort(ALL(cnt));
  int ans = 0;
  rep(i, (int)cnt.size() - k) { ans += cnt[i]; }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 10748
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>

using namespace std;
const double PI = (acos(-1));
const long long MOD = pow(10, 9) + 7;
long long kaizyou(int N);
long long POW(int J);

int main()
{
    long long int A,B;
    cin >> A >> B;
    
    long double X = (A + B)/2.0;
    long long int Y = X;

    if( Y == X)
    {
        long long int C = (A + B)/2;
        cout << C;
    }else
    {
        
        cout << "IMPOSSIBLE";
    }
    

}


Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int t,p,r;
  while(cin>>t>>p>>r,t){
    vector<pair<int,pair<int,int> > >piii;
    int pro[t+10][p+10];
    for(int i=0;i<t+10;i++)
      for(int j=0;j<p+10;j++)
	pro[i][j]=0;
    for(int i=0;i<t;i++)
      piii.pb(mp(INF,mp(0,i+1)));
    for(int i=0;i<r;i++){
      int a,b,c;string str;
      cin>>a>>b>>c>>str;
      a--;
      if(str=="CORRECT"){
	piii[a].F--;
	piii[a].S.F+=c+pro[a][b]*1200;
      }else{
	pro[a][b]++;
      }
    }
    sort(piii.begin(),piii.end());
    for(int i=0;i<t;i++)
      cout<<piii[i].S.S<<" "<<INF-piii[i].F<<" "<<piii[i].S.F<<endl;
  }
  return 0;
}



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

int main() {
	int N,x = 0;
	cin >> N;
	for (;N > 0;N--) {
		char S;
		cin >> S;
		if (S == 'Y'){
			x = 1;
		}
	}
	if (x == 0) {
		cout << "Three" << endl;
	} else {
		cout << "Four" << endl;
	}
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>

//LIFE IS NOT A PROBLEM TO BE SOLVED

using namespace std;

#define rep(i,a,b) for(int i = int(a); i < int(b) ; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

typedef long long int ll;
typedef pair < int, int > ii;
typedef pair < ii, ii > iii;

int main(){
	
	//fflush(stdout);
	//cout.flush();
	
	int n, a, b; 
	cin >> n >> a >> b;
	
	int aux = abs(b-a);
	if(aux&1) puts("Borys");
	else puts("Alice");
	
	return 0;
}

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

typedef long long ll;
typedef long double ld;

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

    int N;
    ll W;
    cin >> N >> W;

    vector<ll> w(N);
    vector<ll> v(N);

    for(int i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
    }

    vector<map<ll, ll> > dp(N);

    dp[0][0] = 0;
    dp[0][w[0]] = v[0];

    for(int i = 1; i < N; i++) {
        for(auto j = begin(dp[i - 1]); j != dp[i - 1].end(); j++) {
            ll x = j -> first;
            ll y = j -> second;
            dp[i][x] = max(dp[i][x], y);
            dp[i][x + w[i]] = max(dp[i][x + w[i]], y + v[i]);
        }
    }

    ll ans = 0;

    for(auto i = begin(dp[N - 1]); i != dp[N - 1].end(); i++) {
        if(i -> first > W) break;
        ans = max(ans, i -> second);
        cerr << i -> first << " " << i -> second << endl;
    }

    cout << ans << endl;
}

Measured memory_bytes: 13952
#include <iostream>
#include <cmath>
using namespace std;
 
int main(){
    while(1){
        int r0,w0,c,r;
        cin >> r0 >> w0 >> c >> r;
        if(r0==0) break;
 
        if(w0*c > r0){
            cout << (int)ceil((double)(w0*c-r0)/r) << endl;
        }else{
            cout << 0 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const int MOD = 1000000007;
int main(){
	int a;
	string s;
	std::cin >> a>>s;
	if(a<3200)std::cout << "red" << std::endl;
	else std::cout << s << std::endl;
}

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

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

int n,V,E,a,b;

struct Edge { int src, dst; double weight; };
using Graph = vector<vector<Edge>>;

Graph g;
vector<int> t;
const int inf = 1e9;

double solve(){
    auto dist = vector<vector<double>>(V, vector<double>(1<<n, inf)); // city, used -> dist
    using State = tuple<double,int,int>; // dist, city, used
    priority_queue<State> q;
    q.emplace(0,a,0);
    dist[a][0] = 0;

    while(q.size()){
        double d;
        int v, used;
        tie(d, v, used) = q.top(); q.pop();
        d = -d;
        if(v == b) return d;
        if(dist[v][used] > d) continue;
        for(auto &e : g[v]){
            rep(i,n){
                if(~used >> i & 1){
                    double nd = d + e.weight / t[i];
                    int nv = e.dst;
                    int nused = used | 1 << i;
                    if(dist[nv][nused] > nd){
                        dist[nv][nused] = nd;
                        q.emplace(-nd, nv, nused);
                    }
                }
            }
        }
    }
    return inf;
}

int main(){
    while(cin >> n >> V >> E >> a >> b && n){
        t.resize(n);
        g.assign(V,{});
        --a; --b;
        rep(i,n) cin >> t[i];
        rep(i,E){
            int x,y;
            double z;
            cin >> x >> y >> z;
            --x; --y;
            g[x].push_back({x,y,z});
            g[y].push_back({y,x,z});
        }

        // for(auto &es : g){
        //     for(auto &e : es){
        //         cout << e.src << ' ' << e.dst << ' ' << e.weight << endl;
        //     }
        // }

        double ans = solve();
        if(ans == inf) cout << "Impossible";
        else cout << fixed << setprecision(10) << ans;
        cout << endl;
    }
}

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

int main(){
    int n;
    cin >> n;
    set<int> s;
    for(int i = 0; i < n; i++){
        int x;  cin >> x;
        s.insert(x);
    }
    cout << s.size() << endl;
    return 0;
}


Measured memory_bytes: 7680
// A.

#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>

using namespace std;

int main(int argc, char *argv[]) {
	int n, m;
	cin >> n >> m;
	cout << (n - 1) * (m - 1) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
typedef long long LL;
const int N = 500050, M = 1 << 20, mod = 1000000007;
int n, a[N], s[N], f[N], ans;
vector<int> g[M];
inline int kasumi(int a, int b){
	int res = 1;
	while(b){
		if(b & 1) res = (LL) res * a % mod;
		a = (LL) a * a % mod;
		b >>= 1;
	}
	return res;
}
int main(){
	scanf("%d", &n);
	for(Rint i = 1;i <= n;i ++){
		scanf("%d", a + i);
		a[i] ^= a[i - 1];
		s[i] = s[i - 1] + (a[i] == 0);
		g[a[i]].push_back(i);
	}
	if(!a[n]) ans = kasumi(2, g[0].size() - 1);
	for(Rint i = 1;i < M;i ++) if(!g[i].empty()) {
		int s1 = 0, s2 = 0;
		for(Rint j = 0;j < g[i].size();j ++){
			f[j] = (1 + (LL) s[g[i][j] - 1] * s1 % mod - s2 + mod) % mod;
			if(!a[n] || g[i][j] == n) ans = (ans + f[j]) % mod;
			s1 = (s1 + f[j]) % mod;
			s2 = (s2 + (LL) f[j] * s[g[i][j]]) % mod;
		}
	}
	printf("%d", ans);
}

Measured memory_bytes: 40308
#include<bits/stdc++.h>
using namespace std;
using ll = long long;


int main() {
	ll A, B, C;
	cin >> B >> A >> C;

	ll ans = 0;
	if (C > 0) {
		ans++;
		C--;
	}
	if(C <= A) {
		cout << ans + A + C << endl;
	}else {
		cout << ans + A + min(A + B, C) << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define SW 1
#define N 110
typedef long long ll;
using namespace std;
ll n,a[N],ck[N];
bool cmp(ll x,ll y){
    return x>y;
}
void input()
{
    scanf("%lld",&n);
    ll i;
    for(i=1;i<=n;i++){
        scanf("%lld",&a[i]);
    }
    sort(a+1,a+1+n,cmp);
}
void process()
{
    ll i;

    if(a[1]!=a[2]){
        printf("Impossible");
        return;
    }
    if(a[1]==1 && n>=3)
    {
        printf("Impossible");
        return;
    }
   // printf("%d ",a[1]);
    for(i=2;i<=a[1];i++){
        ck[max(i-1,a[1]+1-i)]++;
    }
    for(i=3;i<=n;i++){
        if(ck[a[i]]>0){
            ck[a[i]]--;
        }
        else{
            if(a[i]>=(a[1]+3)/2){
                ;
            }
            else
            {
                printf("Impossible");
                return ;
            }
        }
    }
    for(i=0;i<=n;i++){
        if(ck[i]!=0){

            printf("Impossible");
            return;
        }
    }
    printf("Possible");
}
void output()
{

}
int main()
{
#if SW==0
freopen("input.txt","r",stdin);
#endif // SW
    input();
    process();
    output();
    return 0;
}





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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second

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

int n,m;
vector<int> g[5001];
vector<int> ans;
int cnt[5001];
stack<int> s;
bool flg=false;

void tsort() {
	REP(i,n) REP(j,g[i].size()) cnt[g[i][j]]++;

	REP(i,n) if(cnt[i]==0) s.push(i);

	while (s.size()>0) {
		int u=s.top(); s.pop();
		ans.pb(u);
		int num=0;
		REP(i,g[u].size()) {
			int v=g[u][i];
			cnt[v]--;
			if(cnt[v]==0) {
				s.push(v);
				num++;
			}
		}
		if(num>1) flg=true;
	}
}

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

	cin>>n>>m;
	REP(i,m) {
		int a,b; cin>>a>>b; a--;b--;
		g[a].push_back(b);
	}

	tsort();

	REP(i,n) cout<<ans[i]+1<<endl;
	cout<<(flg?1:0)<<endl;

	return 0;
}

Measured memory_bytes: 3788
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int X;
  cin >> X;
  int sum = 0;
  int i = 0;
  while(sum<X){
    sum += i;
    i++;
  }

  cout << i - 1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<stack>
#include<queue>
#include<map>

using namespace std;

int main(){
	string s;
	cin>>s;
	int ans=0;
	char c=s[0];
	for(int i=1;i<s.length();i++){
		if(c!=s[i]){
			ans++;
			c=s[i];
		} 
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
sx, sy, tx, ty = map(int, input().split())
dx, dy = tx-sx, ty-sy
ans = ""
ans += dy*"U" + dx*"R"
ans += dy*"D" + dx*"L"
ans += "L" + (dy+1)*"U" + (dx+1)*"R" + "D"
ans += "R" + (dy+1)*"D" + (dx+1)*"L" + "U"
print(ans)
# UURDDLLUUURRDRDDDLLU
# UURDDLLUUURRDRDDDLLU


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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 1e5 + 9, M = 4e5 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;

int main(){
    init();


    int a, b, c, d; cin >> a >> b >> c >> d;
    int p = 1;
    while(true){
        if(p){
            c -= b;
            if(c <= 0)  return cout << "Yes", 0;
        }
        else{
            a -= d;
            if(a <= 0)  return cout << "No", 0;
        }
        p ^= 1;
    }

}

Measured memory_bytes: 3608