akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static int n;
    static double xa, ya, ra, xb, yb, rb;
    public static void main(String[] args) {
        while(read()){

        }
    }

    static boolean  read(){
        if(!sc.hasNext())return false;
        n = sc.nextInt();
        for(int i = 0; i < n; i++){
            xa = sc.nextDouble();
            ya = sc.nextDouble();
            ra = sc.nextDouble();
            xb = sc.nextDouble();
            yb = sc.nextDouble();
            rb = sc.nextDouble();
            solve();
        }
        return true;
    }

    static void solve(){
        double d = distance();
        if(d > ra+rb){
            System.out.println(0);
        }else if(ra > d+rb){
            System.out.println(2);
        }else if(rb > d+ra){
            System.out.println(-2);
        }else{
            System.out.println(1);
        }
    }

    static double distance(){
        return Math.sqrt((xb - xa)*(xb - xa) + (yb - ya)*(yb - ya));
    }
}

Measured memory_bytes: 12000
N = int(input())  # N角形が作りたい

L = list(map(int, input().split()))  # それぞれの変の長さ
L.sort(reverse=True)

max_L = L[0]

sum = 0
for i in range(1, len(L)):
    sum += L[i]

if max_L < sum:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
import math

def plot(x,y):
    print(f"{x:.8f} {y:.8f}")
def koch(n,x1,y1,x2,y2):
    if n==0:
        plot(x1,y1)
        return
    sx=(2*x1+x2)/3
    sy=(2*y1+y2)/3
    tx=(x1+2*x2)/3
    ty=(y1+2*y2)/3
    ux=(tx-sx)*(1/2)-(ty-sy)*(math.sqrt(3)/2)+sx
    uy=(tx-sx)*(math.sqrt(3)/2)+(ty-sy)*(1/2)+sy
    koch(n-1,x1,y1,sx,sy)
    koch(n-1,sx,sy,ux,uy)
    koch(n-1,ux,uy,tx,ty)
    koch(n-1,tx,ty,x2,y2)
n=int(input())
koch(n,0,0,100,0)
plot(100,0)


Measured memory_bytes: 5756
import sys
input = sys.stdin.readline
Pl = []
Mi = []

N = int(input())
for i in range(N):
    Pl.append(input().rstrip('\n'))
M = int(input())
for i in range(M):
    Mi.append(input().rstrip('\n'))

ans = 0
for s in Pl:
    ans = max(ans, Pl.count(s)-Mi.count(s))
print(ans)


Measured memory_bytes: 9136
using System;
namespace ConsoleApplication1{
    class Program{
        static void Main(string[] args){
            while (true) {
                String str=Console.ReadLine();
                if (str == null) {
                    break;
                }
                String[] strArray = str.Split();
                long[] a = new long[2];
                for (int i = 0; i < 2; i++) {
                    a[i] = long.Parse(strArray[i]);
                }
                Console.WriteLine(gcd(a[0], a[1]) + " " + lcm(a[0], a[1]));
            }
        }
        static long gcd(long a, long b) {
            if (a % b == 0) {
                return b;
            }
            else {
                return gcd(b, a % b);
            }
        }
        static long lcm(long a, long b) {
            return a * b / gcd(a, b);
        }
    }
}

Measured memory_bytes: 5556
(defun app ()
    (let ((x (read))
        (ureshisa 0))
        (incf ureshisa (* 1000 (floor (/ x 500))))
        (setq x (rem x 500))
        (incf ureshisa (* 5 (floor (/ x 5))))
        (format t "~D~%" ureshisa)
    )
)
(app)

Measured memory_bytes: 24296
n,m = map(int,input().split())
a = [int(_) for _ in input().split()]
b = {}
s = 0
for i in range(n):
    s = (s+a[i])%m
    if s not in b:
        b[s] = 1
    else:
        b[s] += 1
res = 0
for key in b:
    res += (b[key]-1)*b[key]//2
if 0 in b:
    res += b[0]    
print(res)

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

int main(){
    string s; cin >> s;
    int n=s.size();
    int ans=0;
    char now=s[0];
    rep2(i,n){
        if(s[i]!=now){
            now=s[i];
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)
#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back

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

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const ll mod = 1e9 + 7;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//

const int nmax = 8;
bool graph[nmax][nmax];

int dfs(int v, int N, bool visited[nmax]){
        bool all_visited = true;

        for(int i = 0; i < N; i++){
                if(visited[i] == false) all_visited=false;
        }
        
        if(all_visited){
                return 1;
        }

        int ret = 0;
        
        for(int i = 0; i < N; i++){
                if(graph[v][i]==false) continue;
                if(visited[i]) continue;

                visited[i]=true;
                ret += dfs(i,N,visited);
                visited[i]=false;
        }

        return ret;
}

int main(void){
        int n,m;
        cin >> n >> m;

        for(int i = 0; i < m; i++){
                int a,b;
                cin >> a >> b;
                graph[a-1][b-1] = graph[b-1][a-1] = true;
        }

        bool visited[nmax];
        for(int i = 0; i < n; i++){
                visited[i] = false;
        }

        visited[0] = true;
        cout << dfs(0,n,visited) << endl;
        return 0;
}










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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }

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

    int H, W;
    std::cin >> H >> W;

    vector<int> char_table(26, 0);
    REP(i, H) {
        REP(j, W) {
            char a;
            std::cin >> a;
            char_table[a - 'a']++;
        }
    }

    priority_queue<int> pq;
    REP(i, 26) {
        if(char_table[i] != 0) pq.push(char_table[i]);
    }

    vector<int> pair_table(3, 0);
    vector<vector<bool>> table(H, vector<bool>(W, false));
    REP(i, H) {
        REP(j, W) {
            auto check = [&](const auto& i, const auto& j) -> int {
                             return !table[i][j] ? table[i][j] = true : 0;
                         };
            if(check(i, j)) {
                auto cnt = 1;
                cnt += check(H - i - 1, j);
                cnt += check(i        , W - j - 1);
                cnt += check(H - i - 1, W - j - 1);
                pair_table[log2(cnt)]++;
            }
        }
    }

    auto ans = "Yes";
    while(!pq.empty()) {
        auto top = pq.top();
        pq.pop();

        auto exec = [&](auto num) {
                        auto div = top / num;
                        top  = top % num;
                        top += max(div - pair_table[log2(num)], 0) * num;

                        pair_table[log2(num)] = max(pair_table[log2(num)] - div, 0);
                    };

        auto prev_pair_table = pair_table;
        if(4 <= top) exec(4);
        if(2 <= top) exec(2);
        if(1 <= top) exec(1);
        if(top != 0) pq.push(top);

        if(pair_table == prev_pair_table) {
            ans = "No";
            break;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


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

int main(){
    int n;cin>>n;
    string s;cin>>s;
    
    int r,b;
    r = b = 0;
    for (auto c:s){
        if (c == 'R'){
            r++;
        } else {
            b++;
        }
    }
    if (r > b){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int w,h;

int main(){
	while(cin >> w >> h,w || h){
		vector<vector<int>> fie(h * 2 + 2,vector<int>(w * 2 + 2,10000));
		rep(i,0,h * 2 + 1)rep(j,0,w * 2 + 1){
			int t = (i % 2) + (j % 2) * 2;
			if(t == 3) fie[i][j] = 10000;
			else if(t == 1 || t == 2) fie[i][j] = 0;
			else fie[i][j] = 1;
		}
		for(int i = 0;i < w - 1;i++){
			int a;
			cin >> a;
			if(a){
				fie[0][1 + i * 2] = 10000;
			}
		}
		for(int i = 1;i <= h - 1;i++){
			for(int j = 0;j < w;j++){
				int a;
				cin >> a;
				if(a){
					fie[i * 2 - 1][j * 2] = 10000;
				}
			}
			for(int j = 0;j < w - 1;j++){
				int a;
				cin >> a;
				if(a){
					fie[i * 2][j * 2 + 1] = 10000;
				}
			}
		}
		using P2 = pair<int,P>;
		priority_queue<P2,vector<P2>,greater<P2>> que;
		que.push({1,{0,0}});
		vector<vector<int>> dist(h * 2 + 2,vector<int>(w * 2 + 2,10000));
		dist[0][0] = 1;
		int dx[] = {1,-1,0,0};
		int dy[] = {0,0,1,-1};
		while(!que.empty()){
			int d= que.top().first;
			int x =que.top().second.first;
			int y = que.top().second.second;
			que.pop();
			if(dist[x][y] < d) continue;
			for(int i = 0;i < 4;i++){
				int nx = x + dx[i];
				int ny = y + dy[i];
				if(0 <= nx && nx < h * 2 && 0 <= ny && ny < w * 2 && dist[nx][ny] > d + fie[nx][ny]){
					dist[nx][ny] = d + fie[nx][ny];
					que.push({dist[nx][ny] , {nx,ny}});
				}
			}
		}

		if(dist[h * 2 - 2][w * 2 - 2] >= 5000){
			dist[h * 2 - 2][w * 2 - 2] = 0;
		}
		cout << dist[h * 2 - 2][w * 2 - 2] << endl;
	}
}



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

typedef long long ll;

int main()
{
   ll n,i,a[100005]={0},x,y,z,high=2000000000,low=0,mid,ans=20000000000;
   cin>>n>>x>>y;
   for(i=0;i<n;i++)
   {
       cin>>a[i];
   }
   while(high>=low)
   {
       mid=(high+low)/2;
       z=0;
       for(i=0;i<n;i++)
       {
           if(mid*y<a[i])
           {
               z+=ceil((1.0*(a[i]-mid*y))/(x-y));
           }
       }
       //cout<<mid<<" "<<z<<" "<<mid<<" "<<low<<" "<<high<< endl;
       if(z<=mid)
       {
           ans=min(ans,mid);
           high=mid-1;
       }
       else
       {
           low=mid+1;
       }
     //  cout<<high<<" "<<low<<endl;
   }
   cout<<ans;

   return 0;
}


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

using ull = unsigned long long;

ull lnum[52];
ull pnum[52];

ull countPatty(int n, ull x) {
    if (n == 0) {
        return 1;
    }
    if (x == 1) {
        return 0;
    }
    if (x <= 1 + lnum[n - 1]) {
        return countPatty(n - 1, x - 1);
    }
    if (x == lnum[n - 1] + 2) {
        return pnum[n - 1] + 1;
    }
    if (x <= 2 + lnum[n - 1] * 2) {
        return pnum[n - 1] + countPatty(n - 1, x - lnum[n - 1] - 2) + 1;
    }
    if (x == 3 + lnum[n - 1] * 2) {
        return pnum[n - 1] * 2 + 1;
    }
    exit(1);
}

int main() {
    int n;
    ull x;
    cin >> n >> x;

    lnum[0] = 1;
    pnum[0] = 1;
    for (int i = 1; i <= n; i++) {
        lnum[i] = lnum[i - 1] * 2 + 3;
        pnum[i] = pnum[i - 1] * 2 + 1;
    }

    cout << countPatty(n, x) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = (int)(n)-1; 0 <= i; i--)
#define rrep1(i, n) for (int i = (int)(n); 1 <= i; i--)

#define each(it, c) \
    for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define all(obj) (obj).begin(), (obj).end()

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x) cerr << #x << " = " << (x) << endl;

#define endl "\n"

template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

typedef long long lint;

using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    lint n, r = 0, ans = 0;
    cin >> n;
    vector<char> c(n);
    rep(i, n) {
        cin >> c[i];
        if (c[i] == 'R') r++;
    }
    rep(i,n){
        if(r==0)break;
        if(c[i]=='R')r--;
        else {
            r--;
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3648
#include  <bits/stdc++.h>
using namespace std;
#define int long long
#define forr(i, n) for(int i = 0;i < (int)n; i++)
#define deb(x) cout<<#x<<" " <<x<<"\n";
#define all(x) x.begin(), x.end()
#define eb emplace_back
#define mp make_pair
#define test int tests;cin >> tests;while(tests--)
#define endl "\n"
const int INF = 2e9;
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int x;
	cin >> x;
	int var = x;
	int ans = 1;
	int lcm = (360LL*x)/gcd(360LL,x);
	ans = lcm/var;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <queue>

using namespace std;

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<int> order(N, 0);
    vector<int> as(N, 0);
    vector<int> bs(N, 0);

    rep(i, N){
        int p;
        cin >> p;
        p --;
        order[p] = i;
    }

    rep(i, N){
        as[i] = 20001 * i + order[i] + 1;
        bs[i] = 20001 * (N - i);
    }

    rep(i, N){
        cout << as[i] << " ";
    }
    cout << endl;

    rep(i, N){
        cout << bs[i] << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<string>
#include<sstream>
#include<cmath>
using namespace std;
#define rep(i, n) for ( int i = 0; i < (int)n; i++)
#define MAX 12
#define INFTY (1<<21)
int W, L[MAX], n;

inline double getL(int r1, int r2){
    return sqrt((r1+r2)*(r1+r2)-(r1-r2)*(r1-r2));
}

void compute(){
    double T[1<<MAX][MAX];
    rep(i, 1<<n) rep(j, n) T[i][j] = INFTY;
    rep(i, n) T[1<<i][i] = L[i]*2;
    rep(i, 1<<n) rep(j, n) rep(l, n){
	if ( (1<<l) & i ) continue;
	T[(1<<l)|i][l] = min(T[(1<<l)|i][l], T[i][j] - L[j] + L[l] + getL(L[j], L[l]));
    }
    double minv = INFTY;
    rep(i, n) minv = min(minv, T[(1<<n)-1][i]);
    if ( minv > W ) cout << "NA" << endl;
    else cout << "OK" << endl;
}

main(){
    string line;
    int l;
    while( getline(cin, line) && !cin.eof() ){
	stringstream sin(line);
	n = 0;
	sin >> W; 
	while( sin >> l ) L[n++] = l;
	compute();
    }
}

Measured memory_bytes: 1308
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll n;
    cin >> n;
    vector<ll>a(n);
    REP(i,n)cin >> a[i];
    ll answer = 0;
    vector<ll> total_sum(n);
    total_sum[0]=0;
    FOR(i,1,n){
        total_sum[i]=(total_sum[i-1]+a[n-i])%MOD;
    }
    reverse(ALL(total_sum));
    REP(i,n){
        answer = (answer+(a[i]*total_sum[i])%MOD)%MOD;
    }

    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 6424
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)
#define all(v) (v).begin(),(v).end()

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    int weight;
    edge(int f,int t,int w) : from(f), to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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;
}

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

int INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

void dfs(string s,char m,int n){
    if(s.size()==n){
        cout << s << endl;
    }
    else{
        for(char c='a'; c<=m; c++){
            dfs(s+c,((c==m)? char(m+1):m),n);
        }
    }
}

int main(){
    int n;
    cin >> n;
    dfs("",'a',n);
}

Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;
typedef long long LL;
LL n,a,b;
int main(){
	cin>>n;
	for(LL i=1;i<=3500;i++)for(LL j=1;j<=3500;j++){
		a=n*i*j;b=4*i*j-(i+j)*n;
		if(b>0&&a%b==0){printf("%lld %lld %lld\n",i,j,a/b);return 0;}
	}
	return 0;
}

Measured memory_bytes: 764
from collections import deque


n = int(input())
info = [list(map(int, input().split())) for i in range(n-1)]
c = list(map(int, input().split()))
c = sorted(c, reverse = True)
tree = [[] for i in range(n)]

for i in range(n-1):
    tree[info[i][0] - 1].append(info[i][1]-1)
    tree[info[i][1] - 1].append(info[i][0]-1)

for i in range(n):
    if len(tree[i]) == 1:
        leaf = i
        break

q = deque([])
q.append([-1, leaf])
visited = [False]*n
visited[leaf] = True
max_ans = 0
ans = [0]*n
j = 0

while q:
    prev_pos, now_pos = q.pop()
    ans[now_pos] = c[j]
    j += 1
    if prev_pos != -1:
        max_ans += min(ans[prev_pos], ans[now_pos])
    for i in tree[now_pos]:
        if not visited[i]:
            visited[i] = True
            q.append([now_pos, i])
print(max_ans)

for i in range(n-1):
    print(str(ans[i]) + " ", end="")
print(ans[n-1], end="")
print()

Measured memory_bytes: 53464
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define PI  3.14159265358979323846
#define M 1000000009
ll gcd(ll a,ll b)
{
    if(a==0)
        return b;
    else
        return gcd(b%a,a);
}
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll res=fast(n/2,a,m)%m;
        if(n%2==0)
            return (((res%m)*(res%m))%m);
        else
            return (((((res%m)*a)%m)*res)%m);
    }
}
int main()
{
  ll a,b;
  cin>>a>>b;
  ll i,j;
  if(a>b)
  {
      for(i=1;i<=a;i++)
      {
          cout<<b;
      }

  }
  else if(b>a)
  {
      for(i=1;i<=b;i++)
      {
          cout<<a;
      }

  }
  else
  {
      for(i=1;i<=a;i++)
      {
          cout<<b;
      }
  }

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589

using namespace std;

int gcd(int a, int b){return (a % b)? gcd(b, a % b) : b;}
int lcm(int a, int b){return a * b / gcd(a, b);}

void solve_A(){
    string s;
    cin >> s;
    if(s[0] != s[1] || s[1] != s[2]) cout  << "Yes";
    else cout << "No";

}
void solve_B(){
    ll n, a, b;
    cin >> n >> a >> b;

    ll ans = 0;
    
    ll count = n / (a+b);
    ll nokori = n - (a+b) * count;

    if(nokori <= a) ans = count * a + nokori;
    else ans = count * a + a;

    cout << ans;
}

void solve_C(){
    int a, b;
    cin >> a >> b;

    int num;
    int ans = 10000;
    for(num = 0; num <= 1000; num++){
        if(floor(num * 0.08) == a && floor(num * 0.10) == b){
            if(ans >= num) ans = num;
            break;
        }
    }
    if(ans == 10000) cout << -1;
    else cout << ans;
    
}

int main(void){
    solve_B();
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void calculate(int a, int b, int n) {
	int i, s = 0;
	a %= b;
	for (i = 0; i < n; i++) {
		a *= 10;
		s += a / b;
		a %= b;
	}
	printf("%d\n", s);
}

int main(void) {
	int a, b, n;
	while (scanf("%d %d %d", &a, &b, &n) != EOF) {
		calculate(a, b, n);
	}
	
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>

using namespace std;

namespace {
    class Dice {
    private:
        vector<int> nums;
    public:
        Dice(int n1, int n2, int n3, int n4, int n5, int n6): nums{n1,n2,n3,n4,n5,n6} {}
        ~Dice() = default;

        int top() { return nums[0]; }

        void move_e() {
            vector<int> tmp;
            tmp.push_back(nums[3]);
            tmp.push_back(nums[1]);
            tmp.push_back(nums[0]);
            tmp.push_back(nums[5]);
            tmp.push_back(nums[4]);
            tmp.push_back(nums[2]);
            nums = tmp;
        }

        void move_n() {
            vector<int> tmp;
            tmp.push_back(nums[1]);
            tmp.push_back(nums[5]);
            tmp.push_back(nums[2]);
            tmp.push_back(nums[3]);
            tmp.push_back(nums[0]);
            tmp.push_back(nums[4]);
            nums = tmp;
        }

        void move_s() {
            vector<int> tmp;
            tmp.push_back(nums[4]);
            tmp.push_back(nums[0]);
            tmp.push_back(nums[2]);
            tmp.push_back(nums[3]);
            tmp.push_back(nums[5]);
            tmp.push_back(nums[1]);
            nums = tmp;
        }

        void move_w() {
            vector<int> tmp;
            tmp.push_back(nums[2]);
            tmp.push_back(nums[1]);
            tmp.push_back(nums[5]);
            tmp.push_back(nums[0]);
            tmp.push_back(nums[4]);
            tmp.push_back(nums[3]);
            nums = tmp;
        }
    };
}

int main() {
    int n1,n2,n3,n4,n5,n6;
    cin >> n1 >> n2 >> n3 >> n4 >> n5 >> n6;

    Dice d(n1,n2,n3,n4,n5,n6);

    string inst;
    cin >> inst;

    for (const char& c : inst) {
        switch(c) {
            case 'E':
                d.move_e();
                break;
            case 'N':
                d.move_n();
                break;
            case 'S':
                d.move_s();
                break;
            case 'W':
                d.move_w();
                break;
            default:
                break;
        }
    }

    cout << d.top() << endl;

    return 0;
}

Measured memory_bytes: 1224
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int H,W;
int dy[4]={0,-1,0,1};
int dx[4]={-1,0,1,0};
string fie[25];
int ansans=0;
int main(){
    cin>>H>>W;
    fie[0]="#####################################";
    for(int i=1;i<=H;i++){
        string s;
        cin>>s;
        fie[i]="#"+s+"#";
    }
    fie[H+1]="#####################################";
    //puts("hoge");
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            if(fie[i][j]=='#')continue;
            int ans[25][25];
            for(int k=0;k<25;k++){
                for(int l=0;l<25;l++)ans[k][l]=10000;
            }
            queue<int> Qx,Qy,Qte;
            Qy.push(i);
            Qx.push(j);
            Qte.push(0);
            ans[i][j]=0;
            while(!Qx.empty()){

                int kariy=Qy.front();Qy.pop();
                int karix=Qx.front();Qx.pop();
                int karite=Qte.front();Qte.pop();
                for(int k=0;k<4;k++){
                    if(fie[kariy+dy[k]][karix+dx[k]]!='#'){
                        if(ans[kariy+dy[k]][karix+dx[k]]>karite+1){
                            Qy.push(kariy+dy[k]);
                            Qx.push(karix+dx[k]);
                            Qte.push(karite+1);
                            ans[kariy+dy[k]][karix+dx[k]]=karite+1;
                            ansans=max(ansans,karite+1);
                        }
                    }
                }
            }
        }
    }
    cout<<ansans<<endl;
    return 0;
}


Measured memory_bytes: 256
// AOJ GRL_4_B Path/Cycle - Topological Sort
// 2018.4.26 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_V 10002
int V;   // 頂点数
int *to[MAX_V], hi[MAX_V];
int q[MAX_V], top, end;
int count[MAX_V];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

void topological_sort()
{
    int i, j, k;

//  for (i = 0; i < V; i++) for (j = 0; j < hi[i]; j++) count[to[i][j]]++;

    top = end = 0;
    for (i = 0; i < V; i++) if (!count[i]) q[end++] = i;
    while (top < end) {
		i = q[top++];
        printf("%d\n", i);
        for (j = 0; j < hi[i]; j++) {
            k = to[i][j];
            if (--count[k] == 0) q[end++] = k;
        }
    }
}

int main()
{
	int E, s, t, i, j;
	int *memo;

	V = in(), E = in();
	memo = malloc(E<<3);
	j = 0; for (i = 0; i < E; i++) {
		memo[j++] = s = in(), memo[j++] = t = in();
		hi[s]++;
	}
	for (i = 0; i < V; i++) if (hi[i]) to[i] = malloc(hi[i]<<2);
	memset(hi, 0, V<<2);
	j = 0; while (E--) {
		s = memo[j++], t = memo[j++];
		to[s][hi[s]++] = t;
		count[t]++;
	}

	topological_sort();
	return 0;
}


Measured memory_bytes: 2592
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  std::string s;

  std::cin >> s;

  std::cout << s.substr(0, s.size() - 8) << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<ll> A,B;
void input(){
    fast_io();
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        ll a,b; cin >> a >> b;
        A.push_back(a);
        B.push_back(b);
        ll midleft = A[N/2];
    }
}

int solve(){
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    if(N%2){
        ll midleft = A[N/2];
        ll midright = B[N/2];
        cout << (midright-midleft+1) << endl;
    }
    else
    {
        ll midleft = (A[N/2-1]+A[N/2]);
        ll midright = (B[N/2-1]+B[N/2]);
        ll ans = (midright-midleft+1);
        cout << ans << endl;

    }
    
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 6688
/*input

*/


// assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ll          long long int
#define pb          push_back
#define pii         pair<ll ,ll >
#define vpii        vector< pii >
#define vi          vector<ll >
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define debug(x)     cout << #x << " " << x << endl;
#define debug_p(x)   cout << #x << " " << x.F << " " << x.S << endl;
#define debug_v(x)   {cout << #x << " "; for (auto ioi : x) cout << ioi << " "; cout << endl;}
#define debug_vp(x)  {cout << #x << " "; for (auto ioi : x) cout << '[' << ioi.F << " " << ioi.S << ']'; cout << endl;}
#define debug_v_v(x) {cout << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cout << ioi2 << " "; cout << '\n';} cout << "*/" << #x << endl;}

int solve()
{
	ll k;cin>>k;
	ll n,m;cin>>n>>m;
	rep(i,n,m+1) if(i%k==0) {cout<<"OK\n"; return 0;}
	cout<<"NG\n";

	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

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

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	//cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 3588
#include<iostream>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  li n; cin >>n;
  li m;
  for(int i=1;(li)i*i<=n;i++){
    if(n%i==0)m=i;
  }
  print(m+n/m-2);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <tuple>
#include <algorithm>
#include <map>
#include <cmath>
#include <tuple>
using namespace std;
long long int MOD = 1000000000 + 7;
using ll = long long;
ll LARGE = 1000000;


int main() {
	vector<int> v{ 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int k;
	cin >> k;

	cout << v[k-1];
	return 0;
}


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

int main(){
	string s;cin>>s;
	deque<char> q;
	for(int i = 0; i < s.size(); i++) {
		q.pb(s[i]);
	}
	ll n;cin>>n;
	ll count = 0;
	for(int i = 0; i < n; i++) {
		int x;cin>>x;
		if (x == 1){
			count ++;
		}
		else{
			int f;char c;cin>>f>>c;
			if (count % 2 == 0){
				if (f == 1){
					q.push_front(c);
				}
				else{
					q.pb(c);
				}
			}
			else{
				if (f == 1){
					q.pb(c);
				}
				else{
					q.push_front(c);
				}
			}
		}
	// 	if(count % 2 == 0){
	// 	for(int i = 0; i < q.size(); i++) {
	// 		cout << q[i];
	// 	}
	// }
	// else {
	// 	for(int i = q.size() - 1; i >= 0; i--) {
	// 		cout << q[i];
	// 	}
	// }
	// cout << endl;
	}
	if(count % 2 == 0){
		for(int i = 0; i < q.size(); i++) {
			cout << q[i];
		}
	}
	else {
		for(int i = q.size() - 1; i >= 0; i--) {
			cout << q[i];
		}
	}
	cout << endl;
	return 0;
}

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

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

    while (1) {
        if (C - B <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
        C -= B;
        if (A - D <= 0) {
            cout << "No" << endl;
            return 0;
        }
        A -= D;
    }
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1e9 + 7;

int main() {
    ll n;
    cin >> n;
    cout << n * (n - 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<stdio.h>
#include<math.h>
#include    <iomanip>
#include    <map>
#include    <set>
#include    <bitset>
using namespace std;
#define FR(i,k,N) for(int i=k;    i<N;i++)
#define REP(i,N) for(int i=0;    i<N;i++)
int a,b;

int main(){
    int sen[10][10001];
    auto maa=0;
    while(cin>>a>>b&&a!=0){
        REP(i, a)REP(j, b) cin>>sen[i][j];
        REP(i, pow(2, a)) {
            bitset<10> senbei(i);
            bitset<10> ichi(1);
            REP(j, a){
                if ((((senbei >> j) & ichi)==1)){
                    REP(k, b) {sen[j][k]=(sen[j][k]+1)%2;}
                }
            }
            int sum=0;
            REP(jj, b){
                int temp=0;
                REP(ii, a){
                    temp+=(sen[ii][jj]+1)%2;
                }
                sum+=max(temp,(a-temp));
            }
            REP(j, a){
                if ((((senbei >> j) & ichi)==1)){
                    REP(k, b) {sen[j][k]=(sen[j][k]+1)%2;}
                }
            }
            maa=(max(maa,sum));
        }
        cout<<maa<<endl;
    }
    return 0;
}

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

int gcd(int a, int b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int d = gcd(a % b, b);
    if (d == 1)
    {
        cout << "YES" << endl;
    }
    else if (d > 1 && c % d == 0)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}

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


int main(){
    int n;
    string s;
    cin >> n >> s;
    int t = s.size();
    rep(i,t){
        if(s[i]+n <= 'Z') cout << char(s[i]+n);
        else cout << char(s[i]+n-'Z'+'A'-1);
    }
}

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

using namespace std;
typedef long long ll;

int main() {
    int n;
    string s;
    cin >> n >> s;

    int ret = 0;
    for (int i = 0; i <= n - 3; i++) {
        if (s.substr(i, 3) == "ABC")ret++;
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int[] num = {scan.nextInt(), scan.nextInt(), scan.nextInt()};
		for(int i = 0; i < 2; i++){
			for(int j = 0; j < 2 - i; j++){
				if(num[j] > num[j+1]){
					int t = num[j];
					num[j] = num[j+1];
					num[j+1] = t;
				}
			}
		}
		System.out.printf("%d %d %d\n", num[0], num[1], num[2]);
	}
}

Measured memory_bytes: 17168
#include<bits/stdc++.h>
    using namespace std;
    //Optimisations
    #pragma GCC target ("avx2")
    #pragma GCC optimization ("unroll-loops")
    #pragma GCC optimize("O2")
    //shortcuts for functions
    #define pb push_back
    #define mp make_pair
    #define ff first 
    #define ss second
    #define all(v) v.begin(),v.end()
    #define prec(n) fixed<<setprecision(n)
    #define n_l '\n'
    // make it python 
    #define gcd __gcd
    #define append push_back
    #define str to_string
    // utility functions shortcuts
    #define max3(a,b,c) max(a,max(b,c))
    #define min3(a,b,c) min(a,min(b,c))
    #define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
    #define swap(a,b) {auto temp=a; a=b; b=temp;}
    #define init(dp) memset(dp,-1,sizeof(dp));
    #define set0(dp) memset(dp,0,sizeof(dp));
    #define bits(x) __builtin_popcount(x)
    #define SORT(v) sort(all(v))
    #define endl "\n"
    #define forr(i,n) for(ll i=0;i<n;i++)
    // declaration shortcuts
    #define ll long long
    // Constants
    constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
    constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
    constexpr ll INF = 1999999999999999997; 
    constexpr int inf= INT_MAX;
    constexpr int MAXSIZE = int(1e6)+5;
    constexpr auto PI  = 3.14159265358979323846L;
    constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
    constexpr auto eps = 1e-6;
    constexpr auto mod = 1000000007;
    constexpr auto MOD = 1000000007;
    constexpr auto MOD9 = 1000000009;
    constexpr auto maxn = 100006;
    //void IOfile(){
    //freopen(file_name, reade_mode, stdin);
    //freopen(file_name, write_mode, stdout);
    //}
    void fastio(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    }
    int main(){
    	fastio();
    	ll h,w;
    	cin>>h>>w;
     
    	if(h==1||w==1){
    		cout<<"1";
    		return 0;
    	}

    	ll ans = ((h+1)/2) * ((w+1)/2) + (h/2) * (w/2);
    	cout<<ans;	
    }

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

#define N 200000 + 5

using namespace std;

int main(){
	int n, p, ans = 0;
	scanf("%d", &n);
	for(int i = 0, min = N; i < n; ++i){
		scanf("%d", &p);
		if(p < min){
			min = p;
			ans++;
		}
	}
	printf("%d", ans);
	return 0;
} 

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

int main(){
  int N;
  int ans=0;
  cin >>N;
  int A[N];
  for (int i=0;i<N;i++){
    cin >>A[i];
  }
  for (int i=0;i<N;i++){
    for (int j=i+1;j<N;j++){
      ans=max(ans,abs(A[i]-A[j]));
    }
  }
  cout <<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int S = sc.nextInt();
        int h = S / 3600;
        int m = (S % 3600) / 60;
        int s = (S % 3600) % 60;
        System.out.println(h + ":" + m + ":" + s);
    }
}


Measured memory_bytes: 26248
/// Swift5 -> Swift2.2

extension String {
    // split(separator:maxSplits:omittingEmptySubsequences:)
    func split(separator separator: Character) -> [String] {
        return self.characters.split(separator).map(String.init)
    }
}
extension Array {
    // init(repeating:count:)
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
    // lastIndex(where:)
    func lastIndex(where predicate: (Element) -> Bool) -> Int? {
      	for i in stride(from: count - 1, through: 0, by: -1) {
          	if predicate(self[i]) {
              	return i
            }
        }
      	return nil
    }
}
extension Array where Element: Comparable {
    // sorted()
    func sorted() -> [Element] {
        return self.sort( { $0 < $1 } )
    }
    // max()
    func max() -> Element? {
        guard self.count > 0 else { return nil }
        return self.reduce(self.first!) { return Swift.max($0, $1) }
    }
}
extension String {
    // Sequence#enumerated()
  	// public func enumerate<Seq : SequenceType>(base: Seq) -> EnumerateSequence<Seq>
    func enumerated() -> EnumerateSequence<[Character]> {
        return Array(self.characters).enumerate()
    }
}
// stride(from:through:by:)
func stride(from start: Int, through end: Int, by stride: Int) -> StrideThrough<Int> {
    return start.stride(through: end, by: stride)
}
// stride(from:to:by)
func stride(from start: Int, to end: Int, by stride: Int) -> StrideTo<Int> {
    return start.stride(to: end, by: stride)
}

/// end

let N = Int(readLine()!)!
let ps = readLine()!.split(separator: " ").map { Double($0)! }

var dp = Array(repeating: 0.0, count: N + 1)
dp[0] = 1 - ps[0]
dp[1] = ps[0]

for i in stride(from: 1, to: N, by: 1) {
    for j in stride(from: i+1, through: 0, by: -1) {
        dp[j] = dp[j] * (1 - ps[i])
        if j > 0 {
            dp[j] += dp[j - 1] * ps[i]
        }
    }
}

print(dp[(N/2+1)...N].reduce(0, combine: +))


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

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define all(x) x.begin(), x.end()

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}

const int MOD = 998244353;

int add(int a, int b) {
	a += b;
	if (a >= MOD)
		a -= MOD;
	return a;
}

int sub(int a, int b) {
	a -= b;
	if (a < 0)
		a += MOD;
	return a;
}

int mul(int a, int b) {
	return (ll) a * b % MOD;
}

int binpow(int a, int n) {
	int ans = 1;
	while (n) {
		if (n & 1) {
			ans = mul(ans, a);
		}
		a = mul(a, a);
		n >>= 1;
	}
	return ans;
}

int inv(int a) {
	return binpow(a, MOD - 2);
}

const int MAXN = 2e5 + 10;

int fact[MAXN], rfact[MAXN];

void build() {
	fact[0] = rfact[0] = 1;
	for (int i = 1; i < MAXN; i++) {
		fact[i] = mul(fact[i - 1], i);
		rfact[i] = inv(fact[i]);
	}
}

int cnk(int n, int k) {
	if (k < 0 || n < k) return 0;
	return mul(fact[n], mul(rfact[k], rfact[n - k]));
}

int n, m, k;

void read() {
	cin >> n >> m >> k;
}

int ans;

void run() {
	ans = 0;
	for (int cnt = 0; cnt <= k; cnt++) {
		int other = n - 1 - cnt;
		int have = cnk(n - 1, other);
		have = mul(have, m);
		have = mul(have, binpow(m - 1, other));
		ans = add(ans, have);
	}
}

void write() {
	cout << ans << endl;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	build();
	read();
	run();
	write();
	return 0;
}

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

int main(void){
    
  int A,B,C,X,ans=0;
  cin >> A >> B >> C >> X;
  
  for(int i=0;i<=A;i++){
      for(int j=0;j<=B;j++){
          for(int l=0;l<=C;l++){
              if(500 * i + 100 * j + 50 * l == X) ans++;
          }
      }
  }
  
  cout << ans << endl;
}

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

////////////
// ModInt //
////////////

// 四則演算の最も左に存在する値がModIntでなければキャストでバグる
// 例えばx = mint * 1000;やx = ModInt(1000) * mint;はいいがx = 1000 * mint;は駄目。
template<int64_t mod_ = 1'000'000'007>
class ModInt {
private:
	int64_t integer_;

public:
	constexpr ModInt(const int64_t initial_number = 0)
		: integer_(initial_number){}
	
	// 四則演算
	constexpr ModInt operator+(const ModInt& operand) const
	{
		ModInt ret{this->integer_ + operand.integer_};
		if (ret.integer_ >= mod_)
			ret.integer_ -= mod_;
		return ret;
	}
	constexpr ModInt operator-(const ModInt& operand) const
	{
		ModInt ret{this->integer_ - operand.integer_};
		if (ret.integer_ < 0)
			ret.integer_ += mod_;
		return ret;
	}
	constexpr ModInt operator*(const ModInt& operand) const
	{
		return {this->integer_ * operand.integer_ % mod_};
	}
	constexpr ModInt operator/(const ModInt& operand) const
	{
		return *this * (operand ^ (mod_ - 2));
	}

	// 累乗
	constexpr ModInt operator^(const int64_t operand) const
	{
		ModInt ret{1}, pow_ope{this->integer_};
		for (int64_t pow{operand}; pow > 0; pow >>= 1)
		{
			if (pow & 1) ret *= pow_ope;
			pow_ope *= pow_ope;
		}
		return ret;
	}

	// 代入
	constexpr ModInt& operator=(const ModInt& operand)
	{
		this->integer_ = operand.integer_;
		return *this;
	}
	constexpr ModInt& operator+=(const ModInt& operand)
	{
		*this = *this + operand;
		return *this;
	}
	constexpr ModInt& operator-=(const ModInt& operand)
	{
		*this = *this - operand;
		return *this;
	}
	constexpr ModInt& operator*=(const ModInt& operand)
	{
		*this = *this * operand;
		return *this;
	}
	constexpr ModInt& operator/=(const ModInt& operand)
	{
		*this = *this / operand;
		return *this;
	}

	// その他
	constexpr operator int64_t() { return integer_; }

	constexpr ModInt getOne() const
	{
		return ModInt(1ll);
	}
	constexpr ModInt getZero() const
	{
		return ModInt(0ll);
	}
};

////////////////
// 組み合わせ //
///////////////

template<int64_t mod_ = 1'000'000'007, int max_ = 200'000>
class Combination {
public:
	std::array<ModInt<mod_>, max_ + 1> inv, fact, finv;

	constexpr Combination()
	{
		inv[0] = inv[1] = fact[0] = fact[1] = finv[0] = finv[1] = 1;
		for (int num{2}; num <= max_; num++)
		{
			inv[num] = (mod_ - (int64_t)inv[mod_ % num] * (mod_ / num) % mod_) % mod_;
			fact[num] = num * fact[num - 1] % mod_;
			finv[num] = inv[num] * finv[num - 1] % mod_;
		}
	}

	constexpr ModInt<mod_> getCombi(const int n, const int r)
	{
		if (r < 0 || n < 0 || n - r < 0) return 0;
		return fact[n] * finv[r] * finv[n - r];
	}

	constexpr ModInt<mod_> getPerm(const int n, const int r)
	{
		if (r < 0 || n < 0 || n - r < 0) return 0;
		return fact[n] * finv[n - r];
	}
};
Combination<> combi;

int main()
{
	int N, K;
	scanf("%d%d", &N, &K);
	N -= K;
	using mint = ModInt<>;
	for (int i{1}; i <= K; i++)
		printf("%lld\n", (int64_t)(combi.getCombi(K - 1, i - 1) * combi.getCombi(N + 1, i)));
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll ;
long long gcd(long long aaa,long long bbb) {
    if(bbb==0) {
        return aaa;
    }
    return gcd(bbb,aaa%bbb);
}

int main (){ 
    
    ll N,x,ans=0;
    cin >> N >> x;
    ll a[N];
    for(ll i = 0; i < N; i++) {
        cin >> a[i];
    }
    sort(a,a+N);
    for(ll i = 0; i < N; i++) {
        if(x - a[i] < 0) {
            cout << ans << endl;
            return 0;
        }else if(x - a[i] == 0) {
            cout << ans+1 << endl;
            return 0;
        }
        x -= a[i];
        ans++;
    }
    cout << ans-1 << endl;
    return 0;
}


Measured memory_bytes: 256