akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<ll,ll> P;

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

#define rep1(i,n) for(ll (i)=1;(i)<=(n);++i)

#define rrep(i,n) for(ll (i)=(n)-1;(i)>=(0);--i)

#define rrep1(i,n) for(ll (i)=(n);(i)>=(1);--i)

#define pb push_back

#define fr first

#define sc second

ll N;

ll A,B;

ll v[50];

vector<ll> vs;


ll cnt;

double ans;

ll res;
ll comb[51][51];



int main()

{
	comb[0][0]=1;
	rep1(i,50){
		comb[i][0]=comb[i][i]=1;
		for(ll j=1;j<i;j++){
			comb[i][j]=comb[i-1][j]+comb[i-1][j-1];
		}
	}

	cin>>N>>A>>B;
	rep(i,N) cin>>v[i];
	sort(v,v+N,[](ll a,ll b){
		return a>b;
	});
	rep(i,A){
		ans+=v[i];
	}
	ans=ans/((double)A);
	printf("%.10lf\n",ans);
	rep(i,N){
		if(i==0||v[i-1]!=v[i]) vs.pb(1);
		else vs[vs.size()-1]++;
	}
	if(vs[0]>A){
		if(vs[0]<=B){
			ll m=0;
			for(ll i=A;i<=vs[0];i++){
				m+=comb[vs[0]][i];
			}
			cout<<m<<endl;
		}
		else{
			ll m=0;
			for(ll i=A;i<=B;i++){
				m+=comb[vs[0]][i];
			}
			cout<<m<<endl;
		}
	}
	else{
		rep(i,vs.size()){
			if(A-vs[i]<0){
				cout<<comb[vs[i]][A]<<endl;
				break;
			}
			A-=vs[i];
		}
	}
}

Measured memory_bytes: 256
s = input()
k = int(input())
len1 = 0
not1 = ''
for i in range(len(s)):
  if s[i] == '1':
    len1 += 1
  else:
    not1 = s[i]
    break

if k <= len1:
  print(1)
else:
  print(not1)

Measured memory_bytes: 3060
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        while(true){
            int h = sc.nextInt(), w = sc.nextInt();
            if(h == 0 && w == 0) break;
            for(int i = 0; i < h; i++){
                for(int n = 0; n < w; n++){
                    if(i == 0 || i == (h - 1)){
                        System.out.print("#");
                    }else if(n == 0 || n == (w - 1)){
                        System.out.print("#");       
                    }else{
                        System.out.print(".");
                    }
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 36920
#include <iostream>

using namespace std;

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

	int res = 0;
	if ( K <= A) {
		res = K;
	} else if (K <= A+B) {
		res = A;
	} else {
		res = A - (K-(A+B));
	}
	
	cout << res << endl;
}


Measured memory_bytes: 3196
#include<stdio.h>

int main()
{
  int W, H, x, y, r;

  scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);

  if(x >= r && W-r >= x && y >= r && H-r >= y) printf("Yes\n");
  else printf("No\n");

  return 0;
}

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

    using namespace std;

    const int MOD=1e9+7;
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        string s,t;
        cin>>s>>t;
        t.pop_back();
        if(s==t)
            cout<<"Yes";
        else
            cout<<"No";
        return 0;
    }


Measured memory_bytes: 3604
#include <vector>

template<typename T>
struct edge {
    int to; T cost;
    edge (int to, T cost = 1) : to(to), cost(cost) { }
    bool operator< (const edge &r) const { return (cost < r.cost); }
};

template<typename T>
using graph = std::vector<std::vector<edge<T>>>;

#include <vector>
#include <limits>

template<typename T>
std::vector<T> bellmanford (const graph<T> &g, int s) {
    const T inf = std::numeric_limits<T>::max();
    int n = int(g.size()), loop = n;
    std::vector<T> dist(n, inf); dist[s] = 0;
    while (loop--) for (int v = 0; v < n; v++) {
        for (const auto &e : g[v]) {
            if (dist[v] == inf) continue;
            if (dist[e.to] > dist[v] + e.cost) {
                if (not loop) return std::vector<T>();
                dist[e.to] = dist[v] + e.cost;
            }
        }
    }
    return dist;
}

#include <iostream>
#include <vector>
#include <limits>

int main() {
    int n, m, r;
    std::cin >> n >> m >> r;
    graph<long long> g(n);
    for (int i = 0; i < m; i++) {
        int src, dst;
        long long cst;
        std::cin >> src >> dst >> cst;
        g[src].emplace_back(dst, cst);
    }

    std::vector<long long> dist = bellmanford(g, r);

    if (dist.size()) {
        for(auto cst : dist) {
            if (cst == std::numeric_limits<long long>::max()) {
                std::cout << "INF" << '\n';
            } else {
                std::cout << cst << '\n';
            }
        }
    } else {
        std::cout << "NEGATIVE CYCLE" << '\n';
    }

    return 0;
}


Measured memory_bytes: 3148
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define EPS 1e-14

#define all(v) v.begin(),v.end()
#define INF 1<<30
#define mp make_pair
#define pb push_back

#define fi first
#define se second

#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

typedef long long ll;

int main(){
	int a,b;
	cin >> a >> b;
	printf("%s\n",(a*b%2==0)?"Even":"Odd");
	return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc107/tasks/arc101_a

import itertools
import collections
import bisect

def main():
    # big value
    INF = int(1e15)

    N, K = map(int, input().split())
    X = [-INF] + list(map(int, input().split())) + [INF]
    pos = bisect.bisect(X, 0) # 0より大きい中で最小の要素のインデックス
    # print(pos)

    right_num = N - pos + 1
    left_num = pos - 1

    ans = INF
    if right_num >= K:  # 右側からだけ取れるなら
        ans = min(ans, abs(X[pos + K - 1]))
    # print(ans)

    for i in range(1, K):  # 左側からいくつ取るか
        if i > left_num:  # 左側に取れるだけ数がないなら continue
            continue
        if K - i > right_num:  # 右側に取れるだけ数がないなら continue
            continue

        left_distance = abs(X[pos - i])
        right_distance = abs(X[pos + K - i - 1])
        # min(一番左までの距離 x 往復 + 一番右までの距離, 一番右までの距離 x 往復 + 一番左までの距離)
        ans = min(ans, left_distance * 2 + right_distance, right_distance * 2 + left_distance)

    if left_num >= K:  # 左側からだけ取れるなら
        ans = min(ans, abs(X[pos - K]))
    # print(ans)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14556
#include <stdio.h>
#include <math.h>
 
int main(void){
  double r, c, s;
 
  while(scanf("%lf", &r) != EOF){
    c = 2.0 * r * M_PI;
    s = r * r * M_PI;
    printf("%lf %lf\n", s, c);
  }
  return 0;
}


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

#define LL long long int
#define rep(k, n) for(LL i=k;i<n;++i)

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
  string s; cin>> s;
  if(s[s.size()-1]=='s') s += "es";
  else s += "s";
  cout<< s<< endl;
}

Measured memory_bytes: 3636
n = int(input())
a = [int(s) for s in input().split(' ')]
counts = [0] * n
for i in a:
  counts[i] += 1
ans = 1 if a[0] == 0 and counts[0] == 1 else 0
for u, v in zip(counts, counts[1:]):
  for _ in range(v):
    ans = ans * u % 998244353
print(ans)

Measured memory_bytes: 14396
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	double r;
	cin >> r;
	printf("%.6lf", (double)r*(double)r*3.141592653589);
	cout << " ";
	printf("%.6lf", (double)r * 2 *3.141592653589);

	return 0;
}

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

using namespace std;

int main() {
  long long a, b, c;
  cin >> a >> b >> c;
  long long ans = min((a % 2) * b * c, min(a * (b % 2) * c, a * b * (c % 2)));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll=long long;

vector<ll> a,b;
ll n,k;
bool check(long long  x)
{
    long long  cnt=0;
    rep(i,n)
    {
        cnt+=max(0ll,a[i]-x/b[i]);
        if(cnt>k)
            return false;
    }
    return true;
}
int main()
{
    ios::sync_with_stdio(0),cin.tie(0);
    cin>>n>>k;
    a.resize(n);
    b.resize(n);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>b[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end(),greater<ll>());
    ll  l=-1,r=1e12+1;
    while(r-l>1)
    {
        ll mid=(l+r)>>1;
        if(check(mid))
            r=mid;
        else
            l=mid;
    }
    cout<<r;
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
void chmax(int &x,int y){if(x < y) x = y;}
void chmin(int &x,int y){if(x > y) x = y;}
int n,m;ll ans,msk[25];
vector<int> v[55],id[55];
vector<int> path;
bool fnd;
void dfs(int x,int fa,int ter){
    //printf("%d %d %d\n",x,fa,ter);
    if(x == ter){
        fnd = 1;
        return;
    }
    rap(i,0,v[x].size()){
        int to = v[x][i];
        if(to == fa) continue;
        path.pb(id[x][i]);
        dfs(to,x,ter);
        if(fnd) return;
        path.pop_back();
    }
}
void dfs2(int x,int num,ll cur){
    if(x == m + 1) {
        int u = __builtin_popcountll(cur);
        if(num & 1) ans -= 1ll << (n - 1 - u);
        else ans += 1ll << (n - 1 - u);
        return;
    }
    dfs2(x+1, num+1, cur | msk[x]);
    dfs2(x+1, num  , cur);
}
int main()
{
    scanf("%d",&n);
    rep(i,1,n-1){
        int t1,t2;
        scanf("%d%d",&t1,&t2);
        v[t1].pb(t2);v[t2].pb(t1);
        id[t1].pb(i);id[t2].pb(i);
    }
    scanf("%d",&m);
    rep(i,1,m) {
        int t1,t2;
        scanf("%d%d",&t1,&t2);
        fnd = 0;
        dfs(t1,0,t2);
        //rap(j,0,path.size()) printf("%d ",path[j]);
        //puts("");
        rap(j,0,path.size()) msk[i] |= 1ll<<(path[j]-1);
        path.clear();
    }
    dfs2(1,0,0);
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3760
import java.util.*;

public class Main {
	public static void main(String[] args){
		Prime p = new Prime();
		int n;
		Scanner sc = new Scanner(System.in);
		
		while(true){
			n = sc.nextInt();
			if(n == 0){
				break;
			}
			System.out.println(p.searchMaxQuadruplet(n));
		}
	}
}

class Prime {
	
	private final int size = 664579;
	private int[] prime;
	
	public Prime(){
		prime = new int[size];
		setPrime();
	}
	
    public void setPrime() {
        int ptr = 0;
        

        prime[ptr++] = 2;
        prime[ptr++] = 3;

        for (int n=5; n<=10000000; n+=2) {
            boolean flag = false;
            for (int i=1; prime[i]*prime[i]<=n; i++) {
                if (0 == n%prime[i]) {
                    flag = true;
                    break;
                }
            }
            
            if (!flag) {
                prime[ptr++] = n;
            }
        }
    }
    
    private int getIndex(int n){
    	for(int i=0; i<size; i++){
    		if(prime[i] > n){
    			return i-1;
    		}else if(prime[i] == n){
    			return i;
    		}
    	}
    	
    	return size-1;
    }
    
    public int searchMaxQuadruplet(int n){
    	int idx = getIndex(n);
    	
    	while(true){
    		if(prime[idx]-prime[idx-1] == 2){
    			if(prime[idx]-prime[idx-2] == 6){
    				if(prime[idx]-prime[idx-3] == 8){
    	    			return prime[idx];
    	    		}
        		}
    		}
    		idx --;
    	}
    	
    }
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll ans = 0, tmp = 10;
    REP(i, 5) {
        ll a;
        cin >> a;
        ans += ceil(a, 10LL) * 10;
        chmin(tmp, (a%10==0?10:a%10));
    }
    cout << ans-10+tmp << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
#define MAX 100
#define WHITE 0
#define BLACK 1
#define GRAY 2
#define INF 1000000
 
void bfs();
int empty();
void enqueue(int);
int dequeue();
 
int num, time, head, tail, inum;
int graph[MAX][MAX];
int dis[MAX];
int color[MAX];
int Q[MAX];
 
int main(){
 
  int i, j, jnum, line;
 
  scanf("%d", &num);
 
  for(i = 0; i < num; i++){
 
    for(j = 0; j < num; j++){
 
      graph[i][j] = 0;
 
    }
 
    scanf("%d %d", &inum, &jnum);
 
    for(j = 0; j < jnum; j++){
 
      scanf("%d", &line);
 
      graph[inum - 1][line - 1] = 1;
 
    }
 
  }
 
  bfs(0);
   
  for(i = 0; i < num; i++){
 
    if(dis[i] == INF)
      printf("%d %d\n", (i + 1), -1);
 
    else
      printf("%d %d\n", (i + 1), dis[i]);
 
  }
 
  return 0;
 
}
 
void bfs(int s){
 
  int u, v;
 
  for(u = 0; u < num; u++){
 
    color[u] = WHITE;
 
    dis[u] = INF;
 
  }
 
  dis[s] = 0;
 
  enqueue(s);
 
  while(empty() == 0){
 
    u = dequeue();
 
    for(v = 0; v < num; v++){
 
      if(graph[u][v] == 0)
    continue;
 
      if(dis[v] != INF)
    continue;
 
      dis[v] = dis[u] + 1;
 
      enqueue(v);
 
    }
 
  }
 
}
 
 
int empty(){
 
  if(head == tail)
    return 1;
 
  else
    return 0;
 
}
 
void enqueue(int data){
 
  Q[tail] = data;
 
  if(tail == MAX) 
    tail = 0;
  else
    tail++;
 
}
 
int dequeue(){
 
  int data;
 
  data = Q[head];
 
  if(head == MAX) 
    head = 0;
 
  else
    head++;
 
  return data;
 
}

Measured memory_bytes: 636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
    private static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

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

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

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

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        Set<Integer> set = new HashSet<>();
        set.add(a);
        set.add(b);
        set.add(c);
        System.out.println(set.size() == 2 ? "Yes" : "No");
    }
}


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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef pair<ll, int> ll_i;
struct edge { int v, w, h; };
const int INF = INT_MAX / 2;
const int MOD = 1e9 + 7;

struct bit {
	vector<ll> v;
	bit(int n) : v(n + 1) {}
	ll sum(int i) {
		ll res = 0;
		for (; i > 0; i -= i & -i) res += v[i];
		return res;
	}
	void add(int i, ll x) {
		for (i++; i < v.size(); i += i & -i) v[i] += x;
	}
};

ll inv(vector<int> a) {
	int N = a.size(), M = 0;
	rep(i, N) M = max(M, a[i] + 1);
	bit b(M);
	ll ans = 0;
	rep(i, N) ans += b.sum(M) - b.sum(a[i] + 1), b.add(a[i], 1);
	return ans;
}

int main() {
	string s; cin >> s;
	int N = s.length();
	vector<vector<int>> v(26);
	rep(i, N) v[s[i] - 'a'].pb(i);
	vector<int> num(26);
	rep(k, 26) num[k] = v[k].size();
	int odd = 0;
	rep(k, 26) if (num[k] % 2) odd++;
	if (odd >= 2) {
		cout << -1 << endl;
		return 0;
	}
	vector<int> a(N);
	rep(k, 26) rep(j, num[k]) {
		int i = v[k][j];
		if (j * 2 + 1 < num[k]) a[i] = 0;
		if (j * 2 + 1 == num[k]) a[i] = 1;
		if (j * 2 + 1 > num[k]) a[i] = 2;
	}
	ll ans = inv(a);
	string s1, s2;
	rep(i, N) if (a[i] == 0) s1.pb(s[i]);
	rep(i, N) if (a[i] == 2) s2.pb(s[i]);
	// cout << s1 << ' ' << s2 << endl;
	int n = s1.length();
	vector<vector<int>> unko(26);
	rep(i, n) unko[s1[i] - 'a'].pb(i);
	vector<int> so(26);
	vector<int> b(n);
	for (int i = n - 1; i >= 0; i--) {
		int k = s2[i] - 'a';
		b[i] = n - 1 - unko[k][so[k]];
		so[k]++;
	}
	ans += inv(b);
	cout << ans << endl;
}


Measured memory_bytes: 4712
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

int i_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int i_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}


int i_gcd(int a, int b);
int i_gcd(int a, int b) {
	if (!b)return a;
	return i_gcd(b, a % b);
}
int i_lcm(int a, int b);
int i_lcm(int a, int b) {
	return (a * b) / i_gcd(a, b);
}
int ll_gcd(ll a, ll b);
int ll_gcd(ll a, ll b) {
	if (!b)return a;
	return ll_gcd(b, a % b);
}
int ll_lcm(ll a, ll b);
int ll_lcm(ll a, ll b) {
	return (a * b) / ll_gcd(a, b);
}

// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
//ll _pfact(ll a);
//static ll pf[100000000];
//static ll pc;
//
//ll _pfact(ll a) {
//	long i, r;
//	if (a % 2 == 0) {
//		pf[pc] = 2; pc++;
//		return(_pfact(a / 2));
//	}
//	r = sqrt(a);
//	for (i = 3; i <= r; i += 2) {
//		if (a % i == 0) {
//			pf[pc] = i; pc++;
//			return(_pfact(a / i));
//		}
//	}
//	if (a != 1) {
//		pf[pc] = a; pc++;
//	}
//	return 0;
//
//}

//同じものの最初の文字をNULLにして降順
int _sort(const void* a, const void* b);
int _sort(const void* a, const void* b) {
	char rc;

	rc = strcmp((char*)b, (char*)a);
	if (rc == 0) {
		*(char*)a = 0x00;
		return(1);
	}
	return(rc);
}
// 立っている ビットの数
int bitcount(unsigned int uc);
int bitcount(unsigned int uc)
{
	int bit;

	for (bit = 0; 0 != uc; uc = (unsigned int)(uc >> 1))
		if (0 != (uc & 1))++bit;

	return bit;
}//bitco

#define _rnd(a,b)    ((a+b-1)/b) //　A/Bの余りを繰り上げる
#define _abs(x) ((x)<0 ? -(x) : (x))
#define _MAX 200000
#pragma endregion

// ABC087 B - Coins

int main(void) {
	int a, b, c, x, cnt = 0;

	scanf("%d %d %d %d", &a, &b, &c, &x);

	x /= 50;
	a = (x/10 < a) ? x/10: a;
	int tmp;
	for (int i = 0; i <= a; i++) {
		tmp = (x - i * 10)/2;
		b = (tmp < b) ? tmp : b;
		for (int j = 0; j <= b; j++) 
			if (x - (i * 10 + j * 2) <= c) 	cnt++;
	}

	printf("%d\n", cnt);
	return 0;
}



Measured memory_bytes: 1704
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const int nmax = 8;
bool graph[nmax][nmax];
 
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
 
ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}
 
ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}
int dfs(int v, ll N, bool visited[nmax])
{
    bool all_visited = true;
 
    for (int i = 0; i < N; i++)
    {
        if (!visited[i])
        {
            all_visited = false;
        }
    }
 
    if (all_visited)
    {
        return 1;
    }
    int ret = 0;
    for (size_t i = 0; i < N; i++)
    {
        if (!graph[v][i])
        {
            continue;
        }
        if (visited[i])
        {
            continue;
        }
 
        visited[i] = true;
        ret += dfs(i, N, visited);
        visited[i] = false;
    }
 
    return ret;
}

void solve(long long N, std::vector<long double> x, std::vector<std::string> u){
    const double Bitcoin = 380000.0;
    long double ans = 0;
    for(int i = 0; i < N; i++)
    {
        if(u[i] == "BTC"){
            ans += x[i] * Bitcoin;
        }else{
            ans += x[i];
        }
    }

    cout << ans << endl;
    
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long double> x(N);
    std::vector<std::string> u(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%Lf",&x[i]);
        std::cin >> u[i];
    }
    solve(N, std::move(x), std::move(u));
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int nums[100005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,L;
    cin>>N>>L;
    
    rep(i,N) cin>>nums[i];
    int idx=-1;
    rep(i,N-1){
        if(L<=nums[i]+nums[i+1]){
            idx=i;break;
        }
    }
    
    if(idx==-1){
        cout1("Impossible")
        return 0;
    }
    
    cout1("Possible")
    for(int i=0;i<idx;i++) cout1(i+1)
    for(int i=N-1;i>idx;i--) cout1(i)
}

Measured memory_bytes: 1280
#include <iostream>
#include <stack>
#include <string>
#include <vector>

int main() {
  std::string s;
  std::cin >> s;

  std::stack<uint32_t> slopes;
  std::stack<std::pair<uint32_t, uint32_t>> lakes;

  std::pair<uint32_t, uint32_t> lake = std::make_pair(0, 0);  // start, area
  for (size_t i = 0; i < s.size(); i++) {
    if (s[i] == '\\') {
      slopes.push(i);
    } else if (s[i] == '/' && !slopes.empty()) {
      lake.first = slopes.top();
      lake.second += i - slopes.top();
      slopes.pop();
    }

    if (lake.second > 0 &&
        (slopes.empty() || s[i] == '\\' || i == s.size() - 1)) {
      while (!lakes.empty() && lake.first < lakes.top().first) {
        lake.second += lakes.top().second;
        lakes.pop();
      }
      lakes.push(lake);
      lake.first = 0;
      lake.second = 0;
    }
  }

  uint32_t sum = 0;
  std::vector<uint32_t> lakes_ans(lakes.size());
  auto itr = lakes_ans.rbegin();
  while (!lakes.empty()) {
    *itr = lakes.top().second;
    sum += *itr;
    lakes.pop();
    itr++;
  }
  std::cout << sum << std::endl;
  std::cout << lakes_ans.size();
  for (auto &&a : lakes_ans) std::cout << " " << a;
  std::cout << std::endl;

  return 0;
}


Measured memory_bytes: 3292
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
constexpr int tv[]={-3,-1,1,3};
constexpr int p10[]={100000000,10000000,1000000,100000,10000,1000,100,10,1};
 
int main(){
    int h,v;
    string a="123456789",b="123456789";
    using data=pair<int,int>;
    
    while(cin>>h>>v, h or v){
        int tc[]={v,h,h,v};
        rep(i,9)cin>>a[i];
        rep(i,9)cin>>b[i];
        int sa=stoi("1"+a)-1000000000,sb=stoi("1"+b)-1000000000;

        unordered_map<int,int> s;

        priority_queue<data> q;
        q.emplace(0,sa);
        
        while(1){
            int cost=q.top().fs;
            int board=q.top().sc;
            q.pop();
            if(board==sb){
                cout<<-cost<<endl;
                break;
            }
            int index=to_string(board).find('0');
            if(index==-1)index=0;
            rep(i,4){
                int fixed=(index+tv[i]+9)%9;
                int next=board;
                int fx=next/p10[fixed]%10;
                next=next-p10[fixed]*fx+p10[index]*fx;
                if((s.find(next)==s.end() || s[next]<cost-tc[i]) && cost-tc[i]>-3000){
                    q.emplace(cost-tc[i], next);
                    s[next]=cost-tc[i];
                }
            }
        }
    }
}



Measured memory_bytes: 21312
def main():
    A, V = map(int, input().split())
    B, W = map(int, input().split())
    T = int(input())
    if V <= W:
        print('NO')
        return
    start = abs(A-B)
    diff = abs(V-W)
    if diff * T >= start:
        print('YES')
    else:
        print('NO')

if __name__ == "__main__":
    main()


Measured memory_bytes: 9180
#include<iostream>

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

int p,q,a;

int solve(int n, int i, int prob, int sum){

	int cnt=0;

	for(; i*prob<=a; i++){
		int right = i*sum + prob;
		int left = i*prob;
		if(right*q > left*p)continue;
		if(right*q == left*p){cnt++;continue;}
		if(n == 1)continue;
		cnt += solve(n-1,i,prob*i,right);
	}
	return cnt;
}


int main(){

	int n;
	while(std::cin >> p >> q >> a >> n,(p||q||a||n)){
		std::cout << solve(n,1,1,0) << std::endl;
	}
	return 0;
}

Measured memory_bytes: 864
#include <bits/stdc++.h>
typedef long long LL;
const int MaxN = 1e5;
using namespace std;

int a[MaxN],n;
int main(){
	int a,b,c;\
	cin>>a>>b>>c;
	if(a+b <c)cout<<"No";
	else cout<<"Yes";

	return 0;	
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(S: str):
    if all([S[i-1] != 'R' if i%2 == 0 else S[i-1] != 'L' for i in range(1, len(S)+1)]):
        print(YES)
    else:
        print(NO)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


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

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

const int INF=1e9;
const int MOD=1e9+7;

int main(){
    int K,T; cin >> K >> T;
    int a[T];
    for(int i=0;i<T;i++){
        cin >> a[i];
    }
    sort(a,a+T);
    int sum=0;
    for(int i=0;i<T-1;i++){
        sum+=a[i];
    }
    int ans=max(a[T-1]-1-sum,0);
    cout << ans << endl;
}

Measured memory_bytes: 3588
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;

template<typename T>void chmax(T &a,T b){a=max(a,b);}
template<typename T>void chmin(T &a,T b){a=min(a,b);}
using namespace std;

void solve(){
	int n;
	cin>>n;
	vector<ll>a(n);
	rep(i,n){
		cin>>a[i];
	}
	sort(a.begin(),a.end());
	for(int i=1;i<n;++i){
		a[i]+=a[i-1];
	}
	ll ans=0;
	int cur=0;
	//吸収するなら小さいを吸収して自分自身を大きくしてからがよい。
	//また、自分の２倍以下なら累積和で考えると自分の３倍以下であればよい。
	while(cur<n){
		int nxt=cur;
		while(nxt<n-1&&3*a[nxt]>=a[nxt+1]){
			++nxt;
		}
		if(nxt==n-1)ans=nxt-cur+1;
		cur=nxt+1;
	}
	cout<<ans<<endl;
}

signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 1024
H,W,N=map(int, input().split())
h,w=map(int, input().split())
S=input()
T=input()
h1,h2,w1,w2=H-h+1,H-h+1,w,w
for i in range(N):
  if S[i]=='U':
    h1+=1
  if h1>H:
    print('NO')
    exit()
  if T[i]=='D':
    h1=max(h1-1,1)
 
  if S[i]=='D':
    h2-=1
  if h2<1:
    print('NO')
    exit()
  if T[i]=='U':
    h2=min(h2+1,H)
  
  if S[i]=='R':
    w1+=1
  if w1>W:
    print('NO')
    exit()
  if T[i]=='L':
    w1=max(w1-1,1)
    
  if S[i]=='L':
    w2-=1
  if w2<1:
    print('NO')
    exit()
  if T[i]=='R':
    w2=min(w2+1,W)

print('YES')

Measured memory_bytes: 3888
#include <stdio.h>
#include <math.h>
int main(void){
	double x,q;
	while(scanf("%lf",&q)!=EOF){
		if(q<0)break;
		else {
			x=q/2;
			while(fabs(x*x*x-q)>=0.00001*q)x=x-((x*x*x-q)/(3*x*x));
			printf("%.6lf\n",x);
		}
	}
	return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if(a*b%2==1){
        cout << "Odd" << endl;
    }else{
        cout << "Even" << endl;

    }
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	alice, bob := 0, 0
	for i, v := range a {
		if i%2 == 0 {
			alice += v
		} else {
			bob += v
		}
	}
	fmt.Println(alice - bob)
}


Measured memory_bytes: 512
n = int(input())
h = list(map(int, input().split()))

ans = 0
while sum(h) != 0:
  flag = False
  for i in range(n):
    if h[i] != 0: flag = True
    if flag == True and h[i] == 0: break
    elif flag == False and h[i] == 0: continue
    h[i] -= 1
  ans += 1
print(ans)

Measured memory_bytes: 9180
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<deque>
using namespace std;

using ll = long long;

int main(void)
{
    int n, m;
    cin >> n >> m;
    int num = 0;
    num += (n * (n - 1)) / 2;
    num += (m * (m - 1)) / 2;

    cout << num << endl;
}


Measured memory_bytes: 256
<?php
$n=trim(fgets(STDIN));
if($n==1){
  echo 0;
  exit;
}
if($n<10){
  echo ($n==6 or $n==8)?2:1;
  exit;
}
$i=2;
$l=min(pow(10,6),ceil(sqrt($n)));
while($i<=$l){
  if($n%$i==0){
    while($n%$i==0){
      $q[$i]+=1;
      $n/=$i;
    }
  }
  ++$i;
}
if(!isset($q)){
  echo 1;
  exit;
}
($n==1)?$ans=0:$ans=1;
foreach($q as $v){
  $i=1;
  while($i<=$v){
    ++$ans;
    $v-=$i;
    ++$i;
  }
}
echo $ans;

Measured memory_bytes: 16172
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	ll l, r;
	cin >> l >> r;
	if (r - l >= 2018) {
		cout << 0 << endl;
		return 0;
	}
	for (ll i = l; i <= r; i++) {
		if (i % 2019 == 0) {
			cout << 0 << endl;
			return 0;
		}
	}
	int ans = 3000;
	for (int i = l % 2019; i < r % 2019; i++) {
		for (int j = i + 1; j <= r % 2019; j++) {
			ans = min(ans, (i*j) % 2019);
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
#define ll long long

const int N = 1e5 + 5;
int n, mod, dp[N], sol[N];
vector<int> g[N], prefix[N], suffix[N];

int add(int a, int b)
{
    return (a + b) % mod;
}

int sub(int a, int b)
{
    return (a - b + mod) % mod;
}

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

void dfs(int node, int parent)
{
    prefix[node] = vector<int>(g[node].size());
    suffix[node] = vector<int>(g[node].size());
    int cur = 1;
    for(int i = 0; i < g[node].size(); i++)
    {
        int child = g[node][i];
        if(child != parent) {
            dfs(child, node);
            cur = mul(cur, dp[child]);
        }
        prefix[node][i] = cur;
    }
    cur = 1;
    for(int i = (int)g[node].size() - 1; i >= 0; i--)
    {
        int child = g[node][i];
        if(child != parent)
            cur = mul(cur, dp[child]);
        suffix[node][i] = cur;
    }
    dp[node] = add(1, cur);
}

int solve(int node, int parent)
{
    sol[node] = dp[node];
    for(int i = 0; i < g[node].size(); i++)
    {
        int child = g[node][i];
        if(child != parent)
        {
            //save data
            int dp1 = dp[node], dp2 = dp[child];

            //change dp[node]
            int p = i ? prefix[node][i - 1] : 1;
            int s = i + 1 < g[node].size() ? suffix[node][i + 1] : 1;
            dp[node] = mul(p, s);
            dp[node] = mul(dp[node], dp[parent]);
            dp[node] = add(dp[node], 1);

            //change dp[child]
            dp[child] = sub(dp[child], 1);
            dp[child] = mul(dp[child], dp[node]);
            dp[child] = add(dp[child], 1);

            //solve
            solve(child, node);

            //undo data
            dp[node] = dp1;
            dp[child] = dp2;
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> n >> mod;
    for(int i = 0; i < n - 1; i++)
    {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1, 1);
    dp[0] = 1;
    solve(1, 0);
    for(int i = 1; i <= n; i++)
        cout << sub(sol[i], 1) << '\n';
    return 0;
}


Measured memory_bytes: 26240
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e3+5;
char a[N];

int main(){
    ll n;cin>>n;
    int i=0;
    while(n){
        char x=(n-1)%26+'a';
        n=(n-1)/26;
        a[i++]=x;
    }
    for(int ii=i-1;ii>=0;ii--)
        cout<<a[ii];
    return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
 
    int a, b;
 
    cin >> a >> b;
 
    int ans = 0;
    ans = ceil(1.0 * (b-1) / (a-1));
    cout << ans << "\n";
}

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

using namespace std;

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

	for (int i = 0; i < N.length(); i++) {
		if (N[i] == '9') {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

}






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

void cnt_up(char& cell) {
    if (cell == '#') return;
    else if (cell == '.') cell = '1';
    else cell++;
}

int main() {
    int H, W;
    std::cin >> H >> W;
    
    std::string temp;
    std::vector<std::string> cells;
    
    for (int i=0; i<H; ++i) {
        std::cin >> temp;
        cells.push_back(temp);
    }
    
    for (int i=0; i<H; ++i) {
        for (int j=0; j<W; ++j) {
            if (cells[i][j] == '#') {
                for (int k=i-1; k<=i+1; ++k) {
                    for (int l=j-1; l<=j+1; ++l) {
                        if (k >= 0 && k < H && l >= 0 && l < W) {
                            cnt_up(cells[k][l]);
                        }
                    }
                }
            }
        }
    }
    
    for (int i=0; i<H; ++i) {
        for (int j=0; j<W; ++j) {
            if (cells[i][j] == '.') cells[i][j] = '0';
        }
    }
    
    for (auto &&e : cells) std::cout << e << std::endl;
}

Measured memory_bytes: 256
#include <iostream>//
#define mod 1000000007
using namespace std;

int n;

int main() {
    cin >> n;
    long long ans = 1;
    for (int i = 0; i < n; ++i) {
        ans %= mod;
        ans *= (i + 1) % mod;
    }

    cout << ans % mod;
    return 0;
}
// Created by Kevin Weng on 2019/11/4.
//



Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
	string O,E;
	string S;
	cin>>O;
	cin>>E;
	int j=0;
	for (int i=0;i<O.length();i++){
		S +=O[i];
		if (j<E.length()){
			S+=E[j++];
		}
	}
	cout<<S.c_str()<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

//しっかり制約確認したか?
int main()
{
    int h, w, k, ans = 0; cin >> h >> w >> k;
    vector<vector<char>> v(h, vector<char>(w));
    rep(i, h) rep(j, w) cin >> v[i][j];
    for(int bit1 = 0; bit1 < (1 << h); bit1++){
        for(int bit2 = 0; bit2 < (1 << w); bit2++){
            int cnt = 0;
            for(int i = 0; i < h; i++){
                for(int j = 0; j < w; j++){
                    if(bit1 & (1 << i) && bit2 & (1 << j)){
                        if(v[i][j] == '#')cnt++;
                    }
                }
            }
            if(cnt == k)ans++;
        }
    }
    cout << ans << endl;
    system("pause");
}


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


int main()
{
    /*A
    int x,a;
    cin>>x>>a;
    if(x<a)
    {
        cout<<0<<endl;
    }
    else
    {
        cout<<10<<endl;
    }
    */

    /*B
    int n,x;
    cin>>n>>x;
    vector <int> l(n);
    rep(i,n)
    {
        cin>>l[i];
    }

    int count=0;
    long long sum=0;
    while(sum<=x)
    {
        sum+=l[count];
        count++;
        if(count==n+1)
        {
            cout<<n+1<<endl;
            return 0;
        }
    }

    cout<<count<<endl;
    */

    long long W,H,x,y;
    cin>>W>>H>>x>>y;
    int count = 0;
    double s=0.0;
    printf("%lf %d\n", double(W)*double(H) / 2, x + x == W&&y + y == H);

    
   
    return 0;
}

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

class Node {
  public:
    vector<int> next_x;
    vector<int> next_y;
    int nlock;
    Node() {
      nlock = 0;
    }
};

int main()
{
  int n;
  cin >> n;
  vector<vector<Node>> node(n);
  for (int i = 0; i < n; i++) {
    node.at(i).resize(i);
  }
  for (int x = 0; x < n; x++) {
    int pre = -1;
    for (int z = 0; z < n-1; z++) {
      int y;
      cin >> y;
      y--;
      if (pre != -1) {
        node.at(max(x, pre)).at(min(x, pre)).next_x.push_back(x);
        node.at(max(x, pre)).at(min(x, pre)).next_y.push_back(y);
        node.at(max(x, y)).at(min(x, y)).nlock++;
      }
      pre = y;
    }
  }
  int ngame = 0;
  int cnt = 0;
  vector<int> game;
  for (int x = 0; x < n; x++) {
    for (int y = 0; y < x; y++) {
      if (node.at(x).at(y).nlock == 0) {
        game.push_back(x*n + y);
      }
    }
  }
  while (ngame < n * (n-1) / 2) {
    if (game.empty()) {
      cnt = -1;
      break;
    }
    cnt++;
    vector<int> next_game;
    for (int g : game) {
      ngame++;
      int x = g / n;
      int y = g % n;
      auto next_x = node.at(x).at(y).next_x;
      auto next_y = node.at(x).at(y).next_y;
      for (int i = 0; i < next_x.size() && i < next_y.size(); i++) {
        if (next_x.at(i) < next_y.at(i)) {
          swap(next_x.at(i), next_y.at(i));
        }
        node.at(next_x.at(i)).at(next_y.at(i)).nlock--;
        if (node.at(next_x.at(i)).at(next_y.at(i)).nlock == 0) {
          next_game.push_back(next_x.at(i) * n + next_y.at(i));
        }
      }
    }
    swap(game, next_game);
  }
  cout << cnt << '\n';
  return 0;
}


Measured memory_bytes: 60800
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    auto f = [](vector<int> v){
        map<int, int> m;
        for (auto &&i : v) m[i]++;
        for (auto &&i : v) i = m[i];
        return v;
    };
    int n;
    while(cin >> n, n){
        vector<int> v(n);
        for (auto &&i : v) scanf("%d", &i);
        int ans = 0;
        while(true){
            auto u = f(v);
            if(u == v) break;
            v = u;
            ans++;
        }
        cout << ans << "\n";
        for (int i = 0; i < n; ++i) {
            if(i) printf(" ");
            printf("%d", v[i]);
        }
        puts("");
    }
    return 0;
}


Measured memory_bytes: 3156
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    ll n, k;
    cin >> n >> k;

    vector<ll> a(n), p;
    map<ll, ll> m;

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

    ll time = 0;
    ll city = 0;
    ll start, end;

    while (true)
    {
        if (m[city] == INF)
        {
            m[city] = time;
            p.push_back(city);
            city = a[city];
        }
        else
        {
            start = m[city];
            end = time;
            break;
        }

        time++;
    }


    if (start > k)
    {
        cout << p[k] + 1 << endl;
        return 0;
    }

    cout << p[(k - start) % (start - end) + start] + 1 << endl;
}

Measured memory_bytes: 19344
import java.io.DataInputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Arrays;
import static java.lang.Math.*;

public class Main {

	public static void main(String[] args) throws Exception {

		byte c;
		int x = 0, y = 0;
		boolean b = true;
		while ( (c = in.read()) != '\n' ) {
			if ( b && c == '1' || !b && c == '0' )
				x++;
			else
				y++;
			b = !b;
		}

		out.println(min(x, y));

	}


	static PrintStream out = System.out;
	static FastReader in = new FastReader();
}

class FastReader {
	final private int BUF_SIZE = 1 << 16;
	private DataInputStream din;
	private byte[] buffer = new byte[BUF_SIZE];
	private int bufferPointer, bytesRead;

	FastReader() {
		din = new DataInputStream(System.in);
	}

	String s() throws IOException {
		byte[] buf = new byte[64];
		int cnt = 0, c;
		while ((c = read()) != -1) {
			if (c == '\n') break;
			buf[cnt++] = (byte) c;
		}
		return new String(buf, 0, cnt);
	}

	int i() throws IOException {
		int ret = 0;
		byte c = read();
		while (c <= ' ') c = read();
		boolean neg = (c == '-');
		if (neg) c = read();
		do {
			ret = ret * 10 + c - '0';
		}
		while ((c = read()) >= '0' && c <= '9');
		return neg ? -ret : ret;
	}

	long l() throws IOException {
		long ret = 0;
		byte c = read();
		while (c <= ' ') c = read();
		boolean neg = (c == '-');
		if (neg) c = read();
		do {
			ret = ret * 10 + c - '0';
		}
		while ((c = read()) >= '0' && c <= '9');
		return neg ? -ret : ret;
	}

	double d() throws IOException {
		double ret = 0, div = 1;
		byte c = read();
		while (c <= ' ') c = read();
		boolean neg = (c == '-');
		if (neg) c = read();
		do {
			ret = ret * 10 + c - '0';
		}
		while ((c = read()) >= '0' && c <= '9');
		if (c == '.')
			while ((c = read()) >= '0' && c <= '9')
				ret += (c - '0') / (div *= 10);
		return neg ? -ret : ret;
	}

	private void fillBuffer() throws IOException {
		bytesRead = din.read(buffer, bufferPointer = 0, BUF_SIZE);
		if (bytesRead == -1) buffer[0] = -1;
	}

/*	private */ byte read() throws IOException {
		if (bufferPointer == bytesRead) fillBuffer();
		return buffer[bufferPointer++];
	}

	void close() throws IOException {
		if (din != null) din.close();
	}
}



Measured memory_bytes: 23124
import java.util.*;

public class Main {

    public static long sum[][] = new long[401][401];
    public static long dp[][] = new long[401][401];

    public static long solve(int s,int e,int arr[]){
        if(s >= e) return 0;
        if(dp[s][e] != -1) return dp[s][e];
        long minCost = (long)(10e12);
        for(int k=s;k<e;k++){
            minCost = Math.min(minCost,sum[s][e] + solve(s,k,arr) + solve(k+1,e,arr));
        }
        return dp[s][e] = minCost;
    }

    public static void preprocess(int n,int arr[]){
        for(int i=1;i<=n;i++){
            for(int j=i;j<=n;j++){
                sum[i][j] = arr[j] + ((i == j) ? 0 : sum[i][j-1]); 
            }
        }
    }

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int arr[] = new int[n+1];
        for(int i=1;i<=n;i++) arr[i] = sc.nextInt();
        for(int i=0;i<=400;i++){
            for(int j=0;j<=400;j++){
                dp[i][j] = -1;
            }
        }
        preprocess(n,arr);
        System.out.println(solve(1,n,arr));
    }

}

Measured memory_bytes: 25940
/*
* Problem Link: https://atcoder.jp/contests/abc042/tasks/abc042_b
*/

#include <bits/stdc++.h>

using namespace std;

int main() {
    int n, l;
    string str;
    vector<string> vs;

    cin >> n >> l;
    for(int i = 0; i < n; cin >> str, vs.push_back(str), i++);
    sort(vs.begin(), vs.end());

    for(int i = 0; i < n; cout << vs[i], i++);
    cout << "\n";
    return 0;
}


Measured memory_bytes: 256