akhauriyash/Code-Regression huggingface dataset:
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*
import kotlin.comparisons.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val (n, a, b) = readListOfInt() 

    println(Math.min(n * a, b))
    pw.flush()
}

/****** Declared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }


// Extensions
fun<T> List<T>.toBuckets(bucketKeys: List<T>): Map<T, Int> {
    val buckets = bucketKeys.associate { t -> Pair(t, 0) }.toMutableMap()
    this.forEach { t ->
        buckets[t] = buckets[t]!! + 1
    }
    return buckets
}

fun <K, V> Map<K, V>.toMutableMap(): MutableMap<K, V> = HashMap(this)

// Util Functions
fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 37640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P3;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
#define REP(i, n) for (int i = 0; i < n; i++)

struct edge{
    ll to, d, cost;
};

ll N, M, L, dmin[105][105]; // dmin[i][j]:頂点iに所持金jで到達する最小コスト
vector<edge> g[105];


ll dijkstra(){
    REP(i,N)fill(dmin[i],dmin[i]+L+1, LLINF/3);
    dmin[0][L] = 0;
    priority_queue<P3, vector<P3>, greater<P3> > que;
    que.push({0,{0,L}});
    while(!que.empty()){
        P3 p = que.top();
        que.pop();
        ll u = p.second.first, l = p.second.second;
        if(dmin[u][l] < p.first) continue;
        for(auto &e : g[u]){
            ll v = e.to, dt=e.d, c = e.cost;
            if(l>=dt && dmin[v][l-dt] > dmin[u][l]){ // 護衛を雇う遷移
                dmin[v][l-dt] = dmin[u][l];
                que.push({dmin[v][l-dt],{v,l-dt}});
            }
            if(dmin[v][l] > dmin[u][l] + c){ // 雇わない遷移
                dmin[v][l] = dmin[u][l] + c;
                que.push({dmin[v][l],{v,l}});
            }
        }
    }
    ll res = LLINF;
    REP(i,L+1){
        res = min(res, dmin[N-1][i]);
    }
    return res;
}

int main() {
    while(1){
        cin >> N >> M >> L;
        if(N==0)break;
        REP(i,N)g[i].clear();
        REP(i,M){
            ll a, b, d, e;
            cin >> a >> b >> d >> e;
            a--;
            b--;
            g[a].push_back({b,d,e});
            g[b].push_back({a,d,e});
        }
        cout << dijkstra() << endl;
    }

    return 0;
}


Measured memory_bytes: 4500
w, h, n = map(int, input().split())
rect = [[1 for _ in range(w)] for _ in range(h)]
def drawx(x, y):
    for i in range(x):
        for j in range(y):
            rect[j][i] = 0

def drawy(x, y):
    for i in range(x, w):
        for j in range(y, h):
            rect[j][i] = 0

for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        drawx(x, h)
    elif a == 2:
        drawy(x, 0)
    elif a == 3:
        drawx(w, y)
    else:
        drawy(0, y)
print(sum(sum(rect, [])))


Measured memory_bytes: 3316
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

using ll = long long;

ll N;

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

  repi( h, 1, 3501 ) repi( n, 1, 3501 )
  {
    ll c = 4*h*n-N*n-N*h;
    ll r = N*h*n;

    if( c && r && r*c > 0 && r % c == 0 )
    {
      ll w = r/c;

      printf( "%lld %lld %lld\n", h, n, w );

      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

const int64_t di[] = {-1, 0, 1, 0};  // Left, Up, Right, Down
const int64_t dj[] = {0, -1, 0, 1};  // Left, Up, Right, Down

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

  int64_t H, W;
  cin >> H >> W;
  vector<vector<bool>> is_open(H, vector<bool>(W, true));
  int64_t count_black = 0;
  for (int64_t i = 0; i < H; ++i) {
    string s;
    cin >> s;
    for (int64_t j = 0; j < W; ++j) {
      const char ch = s.c_str()[j];
      if (ch == '#') {
        is_open[i][j] = false;
        ++count_black;
      }
    }
  }

  // BFS preparation
  queue<Pair> q;
  vector<vector<int64_t>> distances(H, vector<int64_t>(W, kInf));
  auto Update = [&](const Pair target, const int64_t distance) -> void {
    if (distances[target.first][target.second] != kInf) {
      return;
    }
    distances[target.first][target.second] = distance;
    q.emplace(target);
  };

  // BFS
  Update(Pair(0, 0), 0);
  const int64_t d_nexts[][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
  while (!q.empty()) {
    const Pair target = q.front();
    q.pop();
    for (const auto &d : d_nexts) {
      const int64_t next_row = target.first + d[0];
      const int64_t next_col = target.second + d[1];
      if (next_row >= 0 && next_row < H && next_col >= 0 && next_col < W) {
        if (is_open[next_row][next_col]) {
          Update(Pair(next_row, next_col), distances[target.first][target.second] + 1);
        }
      }
    }
  }

  int64_t result = 0;
  if (distances[H - 1][W - 1] == kInf) {
    result = -1;
  } else {
    result = H * W - count_black - (distances[H - 1][W - 1] + 1);
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
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 (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n,m;
cin>>n>>m;
cout<<(n-1)*(m-1)<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<map>
#define LL long long 
using namespace std;

const int M = 210001;
int n,m,k,a[M],s[M],W,ver[M],nex[M],head[M],cnt;
void add(int x,int y)
{
	ver[++cnt]=y, nex[cnt]=head[x], head[x]=cnt;
	ver[++cnt]=x, nex[cnt]=head[y], head[y]=cnt;
}
map<LL,int> mp;
struct vv
{
	LL x;
	int w;
} t[M];

bool cmp(vv a,vv b){return a.x>b.x;}
bool cmp1(vv a,vv b){return a.w<b.w;}

LL dfs(int x,int fa,int dp)
{
	LL S=s[x];
	for(int i=head[x];i;i=nex[i])
	{
		if(ver[i]==fa) continue;
		S+=dfs(ver[i],x,dp+1);
	}
	return S;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&t[i].x);
		t[i].w=i; s[i]=1;
		mp[t[i].x]=i;
	}
	sort(t+1,t+1+n,cmp);
	for(int i=1;i<n;i++)
	{
		LL k=t[i].x+(LL)s[t[i].w]-n+s[t[i].w];
		if(k==t[i].x || mp.find(k)==mp.end())
		{
			printf("-1");
			return 0;
		}
		a[t[i].w]=mp[k];
		add(t[i].w,mp[k]);
		s[mp[k]]+=s[t[i].w];
	}
	LL k=dfs(t[n].w,0,0)-n;
	if(dfs(t[n].w,0,0)-n!=t[n].x) 
	{
		printf("-1");
		return 0;
	}
	for(int i=1;i<n;i++) printf("%d %d\n",t[i].w,a[t[i].w]);
}

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

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

using namespace std;

int main(){
  long long A,B,C,K;
  cin >> A >> B >> C >> K;
  int aa;
  aa=K;
  if(K>=A) aa = A;
  int bb=K-aa;
  if(K-aa>=B) bb=B;
  int cc=K-aa-bb;
  if(K-aa-bb>=C) cc=C;
  cout << aa*1+cc*(-1);

  return 0;
}


Measured memory_bytes: 3624
using System;

namespace Test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var p = Console.ReadLine();

            var add = s.Substring(0, p.Length - 1);
            var check = s + add;

            Console.WriteLine((check.Contains(p)) ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 6208
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
#include<cstring>
#include<string>
#include<functional>

using namespace std;
typedef pair<int,int> P;
typedef long long ll;
int n,m,c,s,g;
int x,y,d,ct;
int p[21],q[21][61],r[21][61];
int fie[101][101][21];
int fie2[101][101];
int dp[101];

int dijk(){
	priority_queue<P,vector<P>,greater<P> > que;
	que.push(P(0,s));
	while(que.size()){
		P q=que.top();
		que.pop();
		int cost=q.first,place=q.second;
		if(dp[place]<cost)continue;
		dp[place]=cost;
		if(place==g)return cost;
		for(int i=1;i<=n;i++){
			int ncost=cost+fie2[place][i];
			if(ncost<dp[i]){
				dp[i]=ncost;
				que.push(P(ncost,i));
			}
		}
	}
	return -1;
}

int main(void){
	while(1){
		scanf("%d%d%d%d%d",&n,&m,&c,&s,&g);
		if(n+m+c+s+g==0)break;
		for(int i=0;i<=20;i++){
			q[i][0]=0;
			for(int j=1;j<=60;j++)q[i][j]=514514191;
			for(int j=0;j<=100;j++){
				for(int k=0;k<=100;k++)fie[j][k][i]=514514191;
				fie[j][j][i]=0;
			}
		}
		for(int i=0;i<=100;i++){
			dp[i]=514514191;
			for(int j=0;j<=100;j++)fie2[i][j]=514514191;
			fie2[i][i]=0;
		}
		for(int i=0;i<m;i++){
			scanf("%d%d%d%d",&x,&y,&d,&ct);
			fie[x][y][ct]=min(fie[x][y][ct],d);
			fie[y][x][ct]=min(fie[y][x][ct],d);
		}
		for(int i=1;i<=c;i++)scanf("%d",&p[i]);
		for(int i=1;i<=c;i++){
			for(int j=1;j<p[i];j++)scanf("%d",&q[i][j]);
			for(int j=0;j<p[i];j++)scanf("%d",&r[i][j]);
		}
		for(int l=1;l<=c;l++){
			for(int k=1;k<=n;k++){
				for(int i=1;i<=n;i++){
					for(int j=1;j<=n;j++)fie[i][j][l]=min(fie[i][j][l],fie[i][k][l]+fie[k][j][l]);
				}
			}
		}
		for(int l=1;l<=c;l++){
			for(int i=1;i<=n;i++){
				for(int j=1;j<=n;j++){
					int lx=0,cost=0;
					if(fie[i][j][l]==514514191)continue;
					while(q[l][lx]<fie[i][j][l]){
						if(q[l][lx+1]<fie[i][j][l])cost+=(q[l][lx+1]-q[l][lx])*r[l][lx];
						else cost+=(fie[i][j][l]-q[l][lx])*r[l][lx];
						lx++;
					}
					fie[i][j][l]=cost;
				}
			}
		}
		for(int l=1;l<=c;l++){
			for(int i=1;i<=n;i++){
				for(int j=1;j<=n;j++)fie2[i][j]=min(fie2[i][j],fie[i][j][l]);
			}
		}
		printf("%d\n",dijk());
	}
	return 0;
}

Measured memory_bytes: 2180
X, N =map(int, input().split())
p_list=list(map(int, input().split()))
#i=N
#1st Xがp_listにあるか
	#あれば+=!
	#なければ答え
#|X-i|=1がp_listにあるか
	#あれば+=!
	#なければ答え

i=N
j=0
while True:
	if X-j not in p_list:
		print(X-j)
		exit()
	elif X+j not in p_list:
		print(X+j)
		exit()
	else:
		j+=1



Measured memory_bytes: 9088
n, m = [int(x) for x in input().split()]

s = input()
c = n

h = []
while True:
	d = m
	while d > 0:
		if c - d >= 0:
			if s[c - d] == '0':
				break
		d -= 1

	if d == 0:
		print(-1)
		break
	
    
    
	c -= d
	h.append(str(d))
	if c == 0:
		h.reverse()
		print(' '.join(h))
		break

Measured memory_bytes: 10100
#include<bits/stdc++.h>
using namespace std;
main(){
  int n;
  cin>>n;
  vector<int> a(n),b;
  for(auto& i:a)cin>>i;
  b=a;
  sort(a.begin(),a.end(),greater<>());
  int fir,sec;
  for(int i=0;i<n;++i){
    if(b[i]==a[0])fir=i;
    if(b[i]==a[1])sec=i;
  }
  for(int i=0;i<n;++i){
    if(i==fir)cout<<a[1]<<"\n";
    else cout<<a[0]<<"\n";
  }
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
int vis[N];
int main(){
	int n;cin>>n;
	int f=1,jg=n&1;
	ll ans=1;
	int cnt=0;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		if(!x) cnt++;
		if(jg&&(x&1)) f=0;
		else if(!jg&&(x%2==0)) f=0;
		else if(jg&&cnt>1) f=0;
		if(!vis[x]){
		if(x) ans=ans*2%mod;
		vis[x]=1;
		} 
	}
	if(!f) cout<<0;
	else cout<<ans; 
	return 0;
}

Measured memory_bytes: 3988
#include<stdio.h>

int isPrime(int x){
  int i;
  if ( x < 2 )return 0;
  else if ( x == 2 )return 1;
  if ( x % 2 == 0)return 0;
  for ( i = 3; i*i <= x; i+= 2) {
    if ( x % i == 0)return 0;
  }
  return 1;
}

int main(){
  int n,x,i;
  int cnt = 0;
   scanf("%d",&n);
  for( i = 0; i< n; i++){
  scanf("%d",&x);
  if ( isPrime(x) )cnt++;
}
printf("%d\n",cnt);

return 0;
}



Measured memory_bytes: 2056
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <bitset>
#include<iomanip>//小数点以下を精度良く表示
#include <map>
#include<set>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define INF 2000000000
#define INF2 1000000000000000000
#define PI 3.1415926535
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> P;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

#define MAX_N 50005//ここにNの最大値を入れる
#define MAX_K 100005



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

int main() {
    int k;
    cin >> k;
    string s;
    cin >> s;
    if (s.length() <= k) {
        cout << s << endl;
        return 0;
    }
    for (int i = 0; i < k; i++) {
        cout << s[i];
    }
    cout << "..." << endl;
    return 0;

}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#define int long long
#define ll getchar();getchar();return 0;
	using namespace std;
	signed main() {
		int a, b;
		string s,l;
		cin >> a >> b;
		cin >> s;
			for (int j = 0; j < a; j++) {
				for (int k = a + 1; k < a+b+1; k++) {
					if (s[a] == '-'&&s[j] != '-'&&s[k] != '-')l = "Yes";
					else l = "No";
				}
			}
		cout << l << endl;
		ll
	}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <functional>
#include <algorithm>
using namespace std;

struct range{ int start, end, pc;};

int main()
{
    int N, M;
    while(cin >> N >> M && N && M) {
        vector< vector<range> > students(M + 1);
        int r, q;
        cin >> r;
        for(int i = 0; i < r; i++) {
            int t, n, m, s;
            cin >> t >> n >> m >> s;
            if(s == 1) {
                students[m].push_back((range){t, -1, n});
            } else {
                for(int j = 0; j < students[m].size(); j++) {
                    if(students[m][j].end == -1 && students[m][j].pc == n) {
                        students[m][j].end = t;
                    }
                }
            }
        }
        cin >> q;
        for(int i = 0; i < q; i++) {
            int ts, te, m, sum;
            cin >> ts >> te >> m;
            sum = 0;
            for(int t = ts + 1; t <= te; t++) {
                for(int j = 0; j < students[m].size(); j++) {
                    if(students[m][j].start < t && students[m][j].end >= t) {
                        sum++;
                        break;
                    }
                }
            }
            cout << sum << endl;
        }
    }
}

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

using namespace std;

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define v(d_type) vector<d_type>
#define loop(i, s, n) for(int i = s; i < n; i++)
#define min(x, y) (x) > (y) ? (y) : (x)
#define max(x, y) (x) < (y) ? (y) : (x)
#define print_vec(X) loop(i, 0, X.size()) cout << X[i] << "\n"

int main()
{
    boost;
    ll l, r, min = 2020;

    cin >> l >> r;

    ll div_l = l/2019;
    ll div_r = r/2019;

    if(div_l != div_r)
        cout << "0\n";
    else
    {
        loop(i, l, r)
            loop(j, i + 1, r + 1)
            {
                ll product = ((i%2019)*(j%2019))%2019;
                if(product < min)
                    min = product;
            }
        cout << min << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <cstring>
#include <stdio.h>
#include <complex>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef long double LD;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<VS> VSS;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i, a, b) for(LL i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i, 0, t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))

const LD PI = acos(-1.0);
const LD EPS = 1e-9;
const LL INF = 1e9;
const LL LINF = 1e18;
const LL mod = 1000000007;
const LL MAXN = 1e5 + 47;
const LL MAX = 45;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);

	LL n;
	cin >> n;
	VLL a(n);
	FOR(i, 0, n)
		cin >> a[i];

	int ans = 1;
	sort(ALL(a));
	VLL s(n);
	s[0] = a[0];
	FOR(i, 1, n)
		s[i] = s[i - 1] + a[i];

	int last_bad = -1;
	FOR(i, 0, n - 1)
	{
		if (s[i]*2LL < a[i+1])
		{
			last_bad = i;
		}
	}

	if (last_bad == -1)
		ans = n;
	else
		ans = n - last_bad - 1;

	cout << ans;
	cin >> n;
	return 0;
}

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

int n, q, t = 0;
struct Id {
    int load;
    char name[20];
};
queue<Id> Q;

int main()
{
    cin >> n >> q;
    for (int i = 0; i < n; i++)
    {
        Id I;
        cin >> I.name >> I.load;
        Q.push(I);
    }
    while (!Q.empty())
    {
        Id &I = Q.front();
        if (I.load <= q)
        {
            t += I.load;
            cout << I.name << " " << t << endl;
        }
        else {
            t += q;
            I.load -= q;
            Q.push(I);
        }
        Q.pop();
    }
    return 0;
}

Measured memory_bytes: 2356
using System;
using System.Linq;
using System.Text;

namespace ALDS1_5_B_MergeSort
{
	class Program
	{
		static void Main ( string[] args )
		{
			int dataCount = int.Parse (Console.ReadLine ());
			int[] numArray = Console.ReadLine ().Split (' ').Select (int.Parse).ToArray ();

			MergeSort (numArray);


			StringBuilder result = new StringBuilder (numArray.Length * 5);

			for (int lp = 0; lp < dataCount - 1; lp++)
			{
				result.Append (numArray[lp] + " ");
			}

			Console.Write (result);
			Console.WriteLine (numArray[numArray.Length - 1]);
			Console.WriteLine (Count);
		}

		static int Count = 0;

		static void MergeSort ( int[] numArray )
		{
			MergeSort (numArray, 0, numArray.Length);
		}

		static void MergeSort ( int[] numArray, int leftIndex, int rightIndex )
		{
			//3?????\??????????´????????????¨???
			//0~1 ??
			//0~2 ???
			if (leftIndex + 1 < rightIndex)
			{
				int middleIndex = (leftIndex + rightIndex) / 2;
				MergeSort (numArray, leftIndex, middleIndex);
				MergeSort (numArray, middleIndex, rightIndex);
				Merge (numArray, leftIndex, middleIndex, rightIndex);
			}
		}

		static void Merge ( int[] numArray, int leftIndex, int middleIndex, int rightIndex )
		{
			int n1 = middleIndex - leftIndex;
			int n2 = rightIndex - middleIndex;

			int[] leftArray = new int[n1 + 1];
			int[] rightArray = new int[n2 + 1];

			for (int index = 0; index < n1; index++)
			{
				leftArray[index] = numArray[leftIndex + index];
			}
			for (int index = 0; index < n2; index++)
			{
				rightArray[index] = numArray[middleIndex + index];
			}

			//sentinel
			leftArray[n1] = int.MaxValue;
			rightArray[n2] = int.MaxValue;

			int left = 0;
			int right = 0;

			for (int index = leftIndex; index < rightIndex; index++)
			{
				Count++;

				if (leftArray[left] <= rightArray[right])
				{
					numArray[index] = leftArray[left];
					left++;
				}
				else
				{
					numArray[index] = rightArray[right];
					right++;
				}
			}
		}
	}
}

Measured memory_bytes: 87780
#include<iostream>
using namespace std;
void print(int arr[],int n)
{
	for (int i = 0; i < n - 1; i++)
		cout << arr[i] << " ";
	cout << arr[n - 1] << endl;
}
int main()
{
	int n, arr[100];
	cin >> n;
	for(int i = 0;i < n;i++)
	{
		cin >> arr[i];
	}
	print(arr, n);
	for(int i = 1;i <= n - 1;i++)
	{
		int key = arr[i];
		int j = i - 1;
		while(j >= 0 && arr[j] > key)
		{
			arr[j + 1] = arr[j];
			j--;
		}
		arr[j + 1] = key;
		print(arr, n);
	}
	return 0;
}


Measured memory_bytes: 3112
#include <algorithm>
#include <cassert>
#include <iostream>
#include <utility>
#include <vector>

const int IMOS_SIZE = 103;

int main()
{
    std::size_t N;
    std::cin >> N;
    std::vector<std::pair<unsigned, std::size_t>> times[3];
    std::vector<unsigned> compressed[3];
    for(std::size_t i = 0; i != N; ++i)
    {
        unsigned a, b, c, d, e, f, g, h, i_, j, k, l;
        std::cin >> a >> b >> c >> d >> e >> f >> g >> h >> i_ >> j >> k >> l;
        times[0].emplace_back(a * 60 + b, i * 2);
        times[0].emplace_back(c * 60 + d, i * 2 + 1);
        times[1].emplace_back(e * 60 + f, i * 2);
        times[1].emplace_back(g * 60 + h, i * 2 + 1);
        times[2].emplace_back(i_ * 60 + j, i * 2);
        times[2].emplace_back(k * 60 + l, i * 2 + 1);
    }
    for(unsigned i = 0; i != 3; ++i)
    {
        std::sort(times[i].begin(), times[i].end());
        compressed[i].resize(N * 2);
        unsigned last = -1;
        unsigned index = 0;
        for(auto val : times[i])
        {
            if(val.first != last)
                ++index;
            compressed[i][val.second] = index;
            last = val.first;
        }
    }
    int imos[IMOS_SIZE][IMOS_SIZE][IMOS_SIZE] = {};
    for(unsigned i = 0; i != N; ++i)
    {
        auto xs = compressed[0][i * 2];
        auto xe = compressed[0][i * 2 + 1] + 1;
        auto ys = compressed[1][i * 2];
        auto ye = compressed[1][i * 2 + 1] + 1;
        auto zs = compressed[2][i * 2];
        auto ze = compressed[2][i * 2 + 1] + 1;
        imos[xs][ys][zs] += 1;
        imos[xs][ys][ze] -= 1;
        imos[xs][ye][zs] -= 1;
        imos[xs][ye][ze] += 1;
        imos[xe][ys][zs] -= 1;
        imos[xe][ys][ze] += 1;
        imos[xe][ye][zs] += 1;
        imos[xe][ye][ze] -= 1;
    }
    for(int z = 0; z < IMOS_SIZE; z++)
    {
        for(int y = 0; y < IMOS_SIZE; y++)
        {
            for(int x = 1; x < IMOS_SIZE; x++)
            {
                imos[z][y][x] += imos[z][y][x - 1];
            }
        }
    }
    for(int z = 0; z < IMOS_SIZE; z++)
    {
        for(int y = 1; y < IMOS_SIZE; y++)
        {
            for(int x = 0; x < IMOS_SIZE; x++)
            {
                imos[z][y][x] += imos[z][y - 1][x];
            }
        }
    }
    for(int z = 1; z < IMOS_SIZE; z++)
    {
        for(int y = 0; y < IMOS_SIZE; y++)
        {
            for(int x = 0; x < IMOS_SIZE; x++)
            {
                imos[z][y][x] += imos[z - 1][y][x];
            }
        }
    }
    // 最大値を調べる
    int tile_max = 0;
    for(int z = 0; z < IMOS_SIZE; z++)
    {
        for(int y = 0; y < IMOS_SIZE; y++)
        {
            for(int x = 0; x < IMOS_SIZE; x++)
            {
                if(tile_max < imos[z][y][x])
                {
                    tile_max = imos[z][y][x];
                }
            }
        }
    }
    std::cout << tile_max << '\n';
}



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

int main() {
    int S ; // 4 digit sequence
    cin >> S;
    int A = S / 100;
    int B = S % 100; 
    if (A >= 01 && A <= 12){
        if (B >= 01 && B <= 12) cout << "AMBIGUOUS";
        else cout << "MMYY";
     } 
     else {
        if (B >= 01 && B <= 12) cout << "YYMM";
        else cout << "NA";
     }
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    int n,cnt=0,cnt2=1;
    cin>>n;
    int arr[n+3];
    int i;
    for(i=0; i<n; i++)
    {
        cin>>arr[i];
    }
    for(i=0; i<n; i++)
    {
        if(arr[i]==cnt2)
        {
            cnt2++;
        }
        else cnt++;
    }
    if(cnt==n)cout<<"-1"<<endl;
    else cout<<cnt<<endl;



    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long n;
    cin >>n;
    long long ans=0;
    long long two=0;
    long long five=0;
    long long temp=n;
    if(n%2==0){
        while(temp>1){
            temp/=(long long)2;
            two+=temp;
          //  cout <<temp<<endl;;
        }
        temp=n/10;
        five=temp;
        while(temp>1){
            temp/=(long long)5;
            five+=temp;
        }
        if(two >five){
            ans=five;
        }else{
            ans=two;
        }
    }
    //cout <<two<<endl;
   // cout <<five <<endl;
    cout<<ans<<endl;
    
}


Measured memory_bytes: 256
N, W = [int(item) for item in input().split()]
item = [[int(item) for item in input().split()] for _ in range(N)]

dp = [[0 for _ in range(W+1)] for _ in range(N+1)]

for i in range(N):
    for w in range(W+1):
        if 0 <= w - item[i][0]:
            dp[i+1][w] = max(dp[i][w], dp[i][w - item[i][0]] + item[i][1])
        else:
            dp[i+1][w] = dp[i][w]
print(dp[N][W])


Measured memory_bytes: 171656
from numpy import*
a,b=map(int,input().split())
c=["0"]*(b+2)
x=[list("0"+input().replace(".","0").replace("#","1")+"0")for i in range(a)]
x.insert(0,c)
x.append(c)
x=array(x).astype(int)
for s in range(1,1+a):
    tmp=""
    for t in range(1,1+b):
        if x[s][t]==1:
            tmp+="#"
        else:
            tmp+=str(sum(x[s-1:s+2,t-1:t+2]))
    print(tmp)

Measured memory_bytes: 12488
// Product Max
package main

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

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	t := sc.Text()
	return strconv.Atoi(t)
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

/*
   xmin xmax ymin ymax
      *    -    *    -  2 xmin*ymin
      -    +    *    -  2 xmin*ymin
      *    -    -    +  2 xmin*ymin
      +    *    *    -  4 xmin*ymax
      *    -    +    *  3 xmax*ymin
      -    +    +    *  1 xmax*ymax
      +    *    -    +  1 xmax*ymax
      +    *    +    *  1 xmax*ymax
      -    +    -    +  5 compare(xmax*ymax, xmin*ymin)
*/
func productMax(xmin, xmax, ymin, ymax int) int {
	if (0 <= xmin && 0 <= ymax) ||
		(0 <= xmax && 0 <= ymin) {
		return xmax * ymax
	}
	if (xmin < 0 && ymax < 0) ||
		(xmax < 0 && ymin < 0) {
		return xmin * ymin
	}
	if 0 <= xmin && ymax < 0 {
		return xmin * ymax
	}
	if xmax < 0 && 0 <= ymin {
		return xmax * ymin
	}
	p := xmax * ymax
	n := xmin * ymin
	if p < n {
		return n
	} else {
		return p
	}
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	a, _ := nextInt(sc)
	b, _ := nextInt(sc)
	c, _ := nextInt(sc)
	d, _ := nextInt(sc)

	fmt.Println(productMax(a, b, c, d))
}


Measured memory_bytes: 1776
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def LIST(): return list(map(int, input().split()))
def MAP(): return map(int, input().split())

ans = []
while 1:
	b = INT()
	if b == 0:
		break

	for n in range(int((2*b)**(1/2)), -1, -1):
		if (2*b - n**2 + n) % (2*n) == 0:
			a = (2*b - n**2 + n) // (2*n)
			break
	ans.append((a, n))

for a, n in ans:
	print(a, n)



Measured memory_bytes: 5896
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int L = sc.nextInt();
		String[] strArray = new String[N];

		for (int i = 0; i < N; i++) {
			strArray[i] = sc.next();
		}

		Arrays.sort(strArray);
		System.out.println(String.join("", strArray));
	}
}


Measured memory_bytes: 23124
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		StringBuilder s = new StringBuilder();
		s.append(scan.next());


		for(int i=s.length()-1;i>=0;i--) {
			s.deleteCharAt(s.length()-1);

			if(s.length()%2==0) {
				String a = s.substring(0,s.length()/2-1);
				String b = s.substring(s.length()/2, s.length()-1);
				if(a.equals(b)) {
					break;
				}
			}
		}
		System.out.println(s.length());
	}

}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
long long arr[100001][3] = {0};
int main()
{
    long long n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            int a;
            cin>>a;
            arr[i][j] = a;
        }
    }
    long long dp[100001][3];
    memset(dp,0,sizeof dp);

    dp[0][0] = arr[0][0];
    dp[0][1] = arr[0][1];
    dp[0][2] = arr[0][2];

    for(int i=1;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            if(j==0)
            {
                dp[i][j] = arr[i][j] + max(dp[i-1][1],dp[i-1][2]);
            }

            if(j==1)
            {
                dp[i][j] = arr[i][j] + max(dp[i-1][0],dp[i-1][2]);   
            }

            if(j==2)
            {
                dp[i][j] = arr[i][j] + max(dp[i-1][0],dp[i-1][1]);
            }
        }
    }   
    long long ans = max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 8176
//Use valgrind once if the submission doesn't go through. It can detect uninitialized variables and see where they could be an issue.
#include <bits/stdc++.h>
using namespace std;

int main(){

	ios_base::sync_with_stdio(false);
    	cin.tie(NULL);

	int a;
	cin>>a;
	cout<<a+a*a+a*a*a<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i <= (n) ; i ++ )
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;

int main() {
  string s;
  cin>>s;
  int n=s.size();
  bool ok=true;
  bool ans=true;
  rep(i,n-1){
  	if(s[i]!=s[n-1-i]){
   	  ok=false;
      break;
  	}
  }
  rep(i,n/2-1){
    if(ok&&s[i]!=s[n/2-1-i]){
       ans=false;
         break;
    }
    else if(!ok){
      ans=false;
    }
  }
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int x,y,tmp;
    while(1){
	scanf("%d %d",&x,&y);
	if(x == 0 && y == 0){
            return 0;
	}
	if(x>y){
	    tmp = x;
	    x = y;
	    y =tmp;
	}
	printf("%d %d\n",x,y);
    }
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;

int main() {
  ll n,m;
  cin >> n >> m;
  vector<set<ll>> check(m);
  for(ll i=0;i<m;i++) {
    ll k;
    cin >> k;
    for(ll j=0;j<k;j++) {
      ll temp;
      cin >> temp;
      temp--;
      check[i].insert(temp);
    }
  }
  vector<ll> p(m);
  for(ll i=0;i<m;i++) {
    cin >> p[i];
  }
  ll ans=0;
  for(ll i=0;i<(1<<n);i++) {
    bitset<10> b(i);
    vector<ll> tans(m);
    for(ll j=0;j<n;j++) {
      if(b.test(j)) {
        for(ll k=0;k<m;k++) {
          if(check[k].count(j)) {
            tans[k]=(tans[k]+1)%2;
          }
        }
      }
    }
    bool flag=true;
    for(ll j=0;j<m;j++) {
      if(tans[j]!=p[j]) {
        flag=false;
        break;
      }
    }
    if(flag) {
      ans++;
    }
  }
  cout << ans << 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 p = pair<int,int>;
 
int main() {
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    if (a+b < k) cout << a + b*0 + (-1)*(k-a-b) << "\n";
    else if (a < k) cout << a << "\n";
    else cout << k << "\n";
    return 0;
}

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

int main(){
    string O,E;
    cin>>O>>E;
    if(O.size()==E.size()){
        for(int i=0;i<O.size();i++){
            cout<<O[i]<<E[i];
        }
        cout<<endl;
    }else{
        for(int i=0;i<E.size();i++){
            cout<<O[i]<<E[i];
        }
        cout<<O[O.size()-1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  ll L, R;
  cin >> L >> R;
  ll ans = L*(L+1)%2019;
  for (ll i=L; i<R; i++) {
    for (ll j=i+1; j<=R; j++) {
      if (i*j%2019==0) {
        ans = 0LL;
        break;
      }
      else ans = min(ans, i*j%2019);
    }
    if (ans==0) break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next());
		int[] A = new int[n];
		int max = 0;
		for (int i = 0; i < n; i++) {
			A[i] = Integer.parseInt(sc.next());
			if (max < A[i])
				max = A[i];
		}
		Arrays.parallelSort(A);

		max++;
		boolean[] primeOfA = new boolean[max];
		boolean[] passedOnce = new boolean[max];
		Arrays.fill(primeOfA, true);
		Arrays.fill(passedOnce, false);

		int count = 0;
		for (int i = 0; i < n; i++) {
			int num = A[i];
			if (passedOnce[num]) { // remove duplicate.
				if (primeOfA[num]) {
					count--;
					primeOfA[num] = false;
				}
				continue;
			}

			passedOnce[num] = true;
			for (int multi = num * 2; multi < max; multi += num)
				primeOfA[multi] = false;

			if (primeOfA[num])
				count++;
		}

		System.out.println(count);
	}
}


Measured memory_bytes: 60284
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define sz(x) ((int) x.size())
#define rd(type, ...) type __VA_ARGS__; sc(__VA_ARGS__)
#define rdv(type, v, n) vector<type> v(n); rep(__ii, 0, n) cin >> v[__ii]
#define rdm(type, v, h, w) vector<vector<type>>(h, vector<type>(w)) v; rep(__ii, 0, h) rep(__jj, 0, w) cin >> v[__ii][__jj]
typedef long long ll;
void solve();
signed main() {ios::sync_with_stdio(false); cin.tie(0);
  cout << fixed; cout.precision(12); solve(); return 0;}
template<typename T> void prv(vector<T> v) {rep(__ii, 0, sz(v)) {if (__ii) cout << ' '; cout << v[__ii];} cout << '\n';} 
template<typename T> void prm(vector<vector<T>> v) {rep(__ii, 0, sz(v)) {rep(__jj, 0, v[__ii].size()) {if (__jj) cout << ' '; cout << v[__ii][__jj];} cout << '\n';}}
template<typename T> void sc(T& x) {cin >> x;}
template<typename Head, typename... Tail> void sc(Head& head, Tail&... tail) {cin >> head; sc(tail...);}
template<typename T> void pr(const T& x) {cout << x << '\n';}
template<typename Head, typename... Tail> void pr(const Head& head, const Tail&... tail) {cout << head << ' '; pr(tail...);}
template<typename... T> void err(const T&... cod) {pr(cod...); exit(0);}

void solve() {
  rd(int, n, a, b);
  pr(min(n * a, b));
}

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

int main() {
	int N = 0;
	int M = 0;
	int a[10000] = { 0 };
	int b[10000] = { 0 };
	int n = 0;
	char fire[10] = { 0 };
	
	cin >> N;
	a[0] = N / 1000;
	a[1] = N % 1000 / 100;
	a[2] = N % 1000 % 100 / 10;
	a[3] = N % 1000 % 100 % 10;

	if (a[0] + a[1] + a[2] + a[3] == 7) {
		cout << a[0] << "+" << a[1] << "+" << a[2] << "+" << a[3] << "=7";
	}
	else if (a[0] + a[1] + a[2] - a[3] == 7) {
		cout << a[0] << "+" << a[1] << "+" << a[2] << "-" << a[3] << "=7";
	}
	else if (a[0] + a[1] - a[2] + a[3] == 7){
		cout << a[0] << "+" << a[1] << "-" << a[2] << "+" << a[3] << "=7";
	}
	else if (a[0] + a[1]-  a[2] - a[3] == 7) {
		cout << a[0] << "+" << a[1] << "-" << a[2] << "-" << a[3] << "=7";
	}
	else if (a[0] - a[1] + a[2] + a[3] == 7) {
		cout << a[0] << "-" << a[1] << "+" << a[2] << "+" << a[3] << "=7";
	}
	else if (a[0] - a[1] + a[2] - a[3] == 7) {
		cout << a[0] << "-" << a[1] << "+" << a[2] << "-" << a[3] << "=7";
	}
	else if (a[0] - a[1] - a[2] + a[3] == 7) {
		cout << a[0] << "-" << a[1] << "-" << a[2] << "+" << a[3] << "=7";
	}
	else {
		cout<< a[0] << "-" << a[1] << "-" << a[2] << "-" << a[3] << "=7";
	}
}



Measured memory_bytes: 256
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define UNIQUE(a) unique(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <cctype>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>
#include <sstream>
#include <map>

using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

const ll mod = 1e9+7;

int main() {
	double w, h, x, y;
	cin >> w >> h >> x >> y;
	
	cout << fixed;
	if ( (x / w == 0.5  && y / h == 0.5) ) {
		cout << setprecision(9) << h * w / 2 << " 1" << endl;
	}
	else{
		cout << setprecision(9) << h * w / 2 << " 0" << endl;
	}

	return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  
  int counter = 0;
  for( ; A<B+1; A++){
    //桁数取得
    int digit;
    for(int i=0; ; i++){
      if(A / (int)(pow(10, i+1)) == 0){
        digit = i;
        break;
      }
      else
        continue;
    }

    //逆さ数取得
    int Y=A, Z=0;
    for( ; digit >=0; digit--){
      Z += (Y % 10) * (int)pow(10, digit);
      //cout << Z << endl;

      Y /= 10;
    }

    //判定
    if(A == Z)
      counter++;
  } 
   
  //出力
  cout << counter << endl;
}


Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
c=[0]*n
ans=0

for i in range (n):
  c[l[i]-1]+=1
  
for j in range (n):
  ans+=int(c[j]*(c[j]-1)/2)

for k in range (n):
  h=c[l[k]-1]
  if h==0 or h==1:
    print (ans)
  else:
    print(ans-int(h*(h-1)/2)+int((h-1)*(h-2)/2))

Measured memory_bytes: 26140
#include <stdio.h>

int p, a[50];

int solve(int i, int m){
  int res;
  if(m == 0)return 1;
  if(i >= p)return 0;

  res = solve(i+1, m) || solve(i+1, m-a[i]);
  return res;
}

int main() {
  int q, i;

  scanf("%d", &p);
  for(i = 0; i < p; i++)scanf("%d", &a[i]);

  scanf("%d", &q);
  int b[q];
  for(i = 0; i < q; i++)scanf("%d", &b[i]);

  for(i = 0; i < q; i++){
    if(solve(0, b[i])==1)printf("yes\n");
    else printf("no\n");
  }
  return 0;
}



Measured memory_bytes: 2080
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from collections import Counter
def resolve():
    n = int(input())

    sieve = list(range(n + 1))
    primes = []
    for i in range(2, n + 1):
        if sieve[i] == i:
            primes.append(i)
        for p in primes:
            if p * i > n or sieve[i] < p:
                break
            sieve[p * i] = p

    ans = 0
    for i in range(1, n):
        C = Counter()
        while i > 1:
            C[sieve[i]] += 1
            i //= sieve[i]
        score = 1
        for val in C.values():
            score *= val + 1
        ans += score
    print(ans)
resolve()

Measured memory_bytes: 80280
tmp = (input().split(" "))
H = int(tmp[0])
W = int(tmp[1])

datas = [input() for i in range(0, H, 1)]

array = []

cnt1 = 0
cnt2 = 0

for data in datas:
  tmp = [x for x in list(data)]
  array.append(tmp)

for i in range(0, H, 1):
  
  a1=0
  a2=0
  a3=0
  a4=0
  
  for j in range(0, W, 1):
    
    if array[i][j] == "#":

      cnt1 += 1
      
      try:
        if array[i][j-1] == "#":
          a1 = 1
        else:
          a1 = 0
      except:
        a1 = 0
        
      try:
        if array[i][j+1] == "#":
          a2 = 1
        else:
          a2 = 0
      except:
        a2 = 0
        
      try:
        if array[i-1][j] == "#":
          a3 = 1
        else:
          a3 = 0
      except:
        a3 = 0
        
      try:
        if array[i+1][j] == "#":
          a4 = 1
        else:
          a4 = 0
      except:
        a4 = 0
        
      if (a1 + a2 + a3 + a4) > 0:
        cnt2 += 1
     
    else:
      continue

if cnt1 == cnt2:
  print("Yes")
else:
  print("No")
    

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

int main() {
	string S;
  ll K;
	cin >> S >> K;
  rep(i,K){
    if(S[i] != '1'){
      cout << S[i] << endl;
      return 0;
    }
  }
  cout << S[K-1] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,n,a) for(int i=n;i>=a;i--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define pcnt(n) __builtin_popcount(n)
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(1){
        c-=b;
        if(c<=0){cout<<"Yes";return 0;}
        a-=d;
        if(a<=0){cout<<"No";return 0;}
    }
}

Measured memory_bytes: 3652
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n,*a = map(int,read().split())

v = sum(a)

x = 0
ans = 1<<60
for i in range(n-1):
    x += a[i]
    ans = min(ans,abs(v-2*x))
    
    
print(ans)






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

struct RollingHash{
    static const int base1 = 1007, base2 = 2009;
    static const int mod1 = 1e9+ 7 , mod2 = 1e9 + 9;
    vector<long long> hash1, hash2, power1, power2;

    // construct
    RollingHash(const string &S){
        int n = (int) S.size();
        hash1.assign(n+1, 0);
        hash2.assign(n+1, 0);
        power1.assign(n+1, 1);
        power2.assign(n+1, 1);
        for(int i = 0; i < n; i++){
            hash1[i+1] = (hash1[i] * base1 + S[i]) % mod1;
            hash2[i+1] = (hash2[i] * base2 + S[i]) % mod2;
            power1[i+1] = (power1[i] * base1) % mod1;
            power2[i+1] = (power2[i] * base2) % mod2;
        }
    }

    // get hash of S[left : right]
    inline pair<long long, long long> get(int l, int r) const {
        long long res1 = hash1[r] - hash1[l] * power1[r-l] % mod1;
        if(res1 < 0) res1 += mod1;
        long long res2 = hash2[r] - hash2[l] * power2[r-l] % mod2;
        if(res2 < 0) res2 += mod2;
        return {res1, res2};
    }

    // get lcp of S[a:] and T[b:]
    inline int getLCP(int a, int b) const{
        int len = min((int) hash1.size()-a, (int)hash1.size()-b);
        int low = 0, high = len;
        while(high - low > 1){
            int mid = (low + high) >> 1;
            if(get(a, a+mid) != get(b, b + mid)) high = mid;
            else low = mid;
        }
        return low;
    }
};

int main(){
    int N;
    string S;
    cin >> N >> S;

    RollingHash rh(S);

    int res = 0;
    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N; j++){
            int lcp = rh.getLCP(i, j);
            lcp = min(lcp, j-i);
            res = max(res, lcp);
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cmath>

int main(){
  
  double W, H, x, y;
  scanf("%lf%lf%lf%lf", &W, &H, &x, &y);
  
  std::cout << std::setprecision(15) << W*H/2.0 << " ";
  
  if(std::abs(W*0.5-x) < 0.1 && std::abs(H*0.5-y) < 0.1){
    std::cout << 1 << std::endl;
  }
  else{
    std::cout << 0 << std::endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 200005
using namespace std;
inline int read(){
	int ans=0;
	char ch=getchar();
	while(!isdigit(ch))ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar();
	return ans;
}
int n,m,first[N],cnt,tot[N][2],is[N];
char s[N];
bool vis[N];
struct edge{int v,next;}e[N<<1];
inline void Add(int u,int v){e[++cnt].v=v,e[cnt].next=first[u],first[u]=cnt;}
inline bool check(int p){
	for(int i=first[p];i;i=e[i].next)if(is[i]==is[p])return true;
	return false;
}
int main(){
	n=read(),m=read();
	scanf("%s",s+1);
	for(int i=1;i<=n;++i)is[i]=s[i]-'A';
	for(int i=1;i<=m;++i){
		int u=read(),v=read();
		Add(u,v),Add(v,u),tot[u][is[v]]++,tot[v][is[u]]++;
	}
	int siz=0;
	queue<int>q;
	for(int i=1;i<=n;++i)if(tot[i][0]==0||tot[i][1]==0)q.push(i),vis[i]=true;
	while(!q.empty()){
		int x=q.front();
		++siz,q.pop();
		for(int i=first[x];i;i=e[i].next){
			int v=e[i].v;
			if(vis[v])continue;
			--tot[v][is[x]];
			if(!tot[v][0]||!tot[v][1])vis[v]=true,q.push(v);
		}
	}
	if(siz==n)cout<<"No";
	else cout<<"Yes";
	return 0;
}

Measured memory_bytes: 7296