akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#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 forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=100005;
int n,num,head[maxn],t[maxn<<1],ne[maxn<<1],deg[maxn];
int a[maxn],root;
bool godie=0;
inline void addedge(int x,int y){
	ne[++num]=head[x];head[x]=num;t[num]=y;
	ne[++num]=head[y];head[y]=num;t[num]=x;
}
inline i64 dfs(int x,int f){
	if(deg[x]==1){
		return a[x];
	}i64 sum=0,maxi=0;
	forE(i,x)if(t[i]!=f){
		i64 v=dfs(t[i],x);
		sum+=v;maxi=max(maxi,v);
	}
	if(sum<a[x]){
		godie=1;
		return 0;
	}
	i64 del=min(sum/2,sum-maxi);
	if(sum-a[x]>del){
		godie=1;
		return 0;
	}
	sum-=(sum-a[x])*2;
	//assert(sum>=0);
	return sum;
}
int main(){
	read(n);
	rep(i,1,n)read(a[i]);
	rep(i,1,n)head[i]=-1;
	rep(i,1,n-1){
		int x,y;read(x);read(y);
		addedge(x,y);
		deg[x]++;deg[y]++;
	}
	int rt=0;
	rep(i,1,n)if(deg[i]!=1){
		rt=i;break;
	}
	if(rt==0){
		if(a[1]==a[2]){
			puts("YES");
		}else{
			puts("NO");
		}return 0;
	}
	i64 x=dfs(rt,-1);
	if(x==0&&!godie){
		puts("YES");
	}else{
		puts("NO");
	}
	return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
    double a[1010], n, s, k=0, i=0;
    cin >> n;
    for(i=0; i<n;i++){
             cin>>a[0]>>a[1]>>a[2];
             sort(a, a+3);
             k=(a[1]*a[1])+(a[0]*a[0]);
             if(a[2]==sqrt(k))
             cout<<"YES\n";
             else
             cout<<"NO\n";
    }
    return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  int a[100000];
  int b[100000]={0};
  rep(i,n){
    cin>>a[i];
  }
  sort(a,a+n);
  rep(i,n){
    int num=a[i];
    while(num){
      num/=2;
      b[i]++;
    }
  }
  while(m){
    sort(a,a+n);
    int now=b[n-1];
    if(now==0) break;
    repn(i,n-1){
      if(b[i]==now){
	b[i]--;
	a[i]/=2;
	m--;
      }
      if(m==0) break;
    }
  }
  
    
    
  int ans=0;
  rep(i,n){
    ans+=a[i];
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 1792
import java.io.*;
import java.util.*;
public class Main {
	static PrintWriter out = new PrintWriter(System.out); 

	public static void main(String[] args)throws Exception {
		try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
			
			int n = Integer.parseInt(br.readLine());
			
			Map<String,Integer> map = new HashMap<>();
			int max = 0,tmp = 0;
			for(int i = 0; i < n; i++) {
				String s =  br.readLine(); 
				
				if(map.containsKey(s)) {
					tmp = map.get(s)+1;
					map.put(s,tmp);
					max = Math.max(tmp, max);
				}else {
					map.put(s,1);
					max = Math.max(max, 1);
				}

				
			}
			
			List<String> list = new ArrayList<>();
			for(String key: map.keySet()) {
				if(map.get(key)==max) {
					list.add(key);
				}
			}
			
			Collections.sort(list);
			
			for(String a: list) {
				System.out.println(a);
			}
			
		}		
		
		
	}

}


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

int main(){
  string S;
  int a=0,b=0;
  cin >> S;
  for(int i=0;i<S.length();i++){
    if(i%2==0 && S[i]=='1') a++;
    else if(i%2==1 && S[i]=='0') a++;
  }
  for(int i=0;i<S.length();i++){
    if(i%2==1 && S[i]=='1') b++;
    else if(i%2==0 && S[i]=='0') b++;
  }
  cout << min(a,b) << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
	const double PI = 3.14159265359;
	double r = 0;
	cin >> r;

	cout << fixed << setprecision(6);
	cout << PI * r * r << " " << 2 * PI * r << endl;

	return 0;
}

Measured memory_bytes: 3280
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

ll expo(ll a, ll b){
    ll ex = 1;
    rep(i, b){
        ex *= a;
    }
    return ex;
}

ll fact(ll a){
    ll fc = 1;
    REP(i, 1, a+1){
        fc *= i;
    }
    return fc;
}

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    ll c1 = abs(a-b) + abs(a-c);
    ll c2 = abs(a-b) + abs(b-c);
    ll c3 = abs(a-c) + abs(b-c);
    cout << min(c1, min(c2, c3)) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<fstream>
#include<algorithm>
using namespace std;
using ll = long long;

int main(){
    string str;
    cin >> str;
    bool flag = true;
    for(int i=0;i<str.size();i++){
        if(i%2==0){
            if(!(str[i]=='R'||str[i]=='U'||str[i]=='D'))    flag = false;
        }
        else{
            if(!(str[i]=='L'||str[i]=='U'||str[i]=='D')) flag = false;
        }
    }
    if(flag)    cout << "Yes";
    else    cout << "No";
}   

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    string s; cin >> s;
    int a=0;
    rep(i,(int)s.size()) if (s.at(i)=='1') a++;
    cout << a << endl;
}

Measured memory_bytes: 3572
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

using ll = long long;

int main() {
    int V, E, s, t, d;
    cin >> V >> E;
    vector<vector<ll>> dist(V, vector<ll>(V, 1e18));
    rep(i, V) dist[i][i] = 0;
    rep(i, E) {
        cin >> s >> t >> d;
        dist[s][t] = d;
    }
    rep(k, V) {
        rep(i, V) {
            rep(j, V) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    rep(i, V) {
        if (dist[i][i] < 0) {
            cout << "NEGATIVE CYCLE\n";
            return 0;
        }
    }
    rep(i, V) {
        rep(j, V) {
            if (dist[i][j] > 1e17) cout << "INF";
            else cout << dist[i][j];
            if (j == V - 1) cout << "\n";
            else cout << " ";
        }
    }
}


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

int main(){
    int N;
    long long K;
    cin >> N >> K;
    vector<int>A(N), B(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
        A.at(i)--;
        B.at(i) = -1;
    }
    int i = 0, j = 0;
    while(B.at(i) == -1) {
        B.at(i) = A.at(i);
        i = B.at(i);
        j++;
    }
    int k = 0, l = 0;
    while(k != i) {
        k = A.at(k);
        l++;
    }
    int ans = 0;
    if (K <= l) {
        for (int i = 0; i < K; i++) {
            ans = A.at(ans);
        }
    }
    else {
        ans = i;
        for (int i = 0; i < (K-l)%(j-l); i++) {
            ans = A.at(ans);
        }
    }
    cout << ans + 1;
}

Measured memory_bytes: 4812
c11,c12,c13 = map(int, input().split())
c21,c22,c23 = map(int, input().split())
c31,c32,c33 = map(int, input().split())

out = 'No'
if c13-c11 == c23-c21 == c33-c31:
  if c11-c12 == c21-c22 == c31-c32:
    if c12-c13 == c22-c23 == c32-c33:
      out = 'Yes'
      
print(out)

Measured memory_bytes: 3060
s=input()
#s="RRLLLLRLRRLL"
a = [0] * len(s)
l_first = 0
r_first = 0

for i in range(len(s)):
    ii =len(s)-i-1
    if s[ii] == "R":
        if r_first==0:
            d = len(s)-ii-1
            r_first=ii
            a[ii+1]+=int(d/2)+d%2
            a[ii]+=int(d/2)
        else:
            d = -ii+r_first-1
            r_first=ii
            a[ii+1]+=int(d/2)+d%2
            a[ii]+=int(d/2)    
for i in range(len(s)):
    if s[i] == "L":
        if l_first==0:
            d = i-l_first
            l_first=i
            a[i-1]+=int(d/2)+d%2
            a[i]+=int(d/2)
        else:
            d = i-l_first-1
            l_first=i
            a[i-1]+=int(d/2)+d%2
            a[i]+=int(d/2)
print(" ".join(list(map(str,a))))

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

int main(){
    int p, q, r;
    cin >> p >> q >> r;
    
    if(p+q < p+r && p+q < r+q){
        cout << p+q << endl;
    }else if(p+r < r+q){
        cout << p+r << endl;
    }else{
        cout << r+q << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int sum=0,maxx=0;
	for(int i=0;i<n;i++){
		if(s[i]=='I'){
			sum++;
		}
		else sum--;
		maxx=max(sum,maxx);	
	}
	cout<<maxx<<endl;
	return 0;
}

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


int main() {
    int A,B;
    char o;
    cin >> A >> o >> B;
    if (o == '+'){
        cout << A+B << endl;
    }else{
        cout << A-B << endl;
    }

}       

Measured memory_bytes: 256
#include <iostream>

int main() {
    int x;
    std::cin >> x;

    int a = x / 500; //a * 1000 to get happiness so far
    x -= a * 500;
    int b = x / 5; // b * 5 + a total happiness possible
    std::cout << a * 1000 + b * 5;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef pair<int,int>P;
typedef long long ll;

ll dp[70][2];

ll calc(ll B,int l){
	memset(dp,0,sizeof(dp));
	if(B<0)return 0;
	dp[0][0]=1;
	rep(i,60)rep(j,2){
		int lim=(j?1:((B>>(59-i))&1));
		rep(k,lim+1){
			if(i==l&&k!=1)continue;
			dp[i+1][j||k<lim]^=dp[i][j];
		}
	}
	return dp[60][0]^dp[60][1];
}
int main(){
	ll A,B;cin>>A>>B;A--;
	ll ans=0;
	rep(i,60){
		ans+=(1LL<<i)*(calc(B,59-i)^calc(A,59-i));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
	string str;
	cin >> str;
	int res = 0;
	for (int i = 0; i < str.length(); ++i) {
		if (str[i] == '+') {
			++res;
		}
		else {
			--res;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.math.*;
 
class Main {
    public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    public static PrintWriter pw = new PrintWriter(System.out);
    public static String line;
    public static StringTokenizer st;
    public static ArrayList<ArrayList<Integer>> adjList;
    public static int[] dx = {-1, 0, 1, 0, -1, 1, 1, -1, 0};
    public static int[] dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
    public static int INF = 0x3f3f3f3f;
    public static int MOD = 1000000007;
    public static long LINF = 0x3f3f3f3f3f3f3f3fL;

    public static void main(String[] args) throws Exception {
        int N = Integer.parseInt(br.readLine());
        st = new StringTokenizer(br.readLine());
        long[] A = new long[N];
        for(int i = 0; i < N; i++) {
            A[i] = Integer.parseInt(st.nextToken());
        }

        HashMap<Long, Integer> d = new HashMap<Long, Integer>();

        long ans = 0;
        long mask = 0;
        for (int i = 0; i < N; i++) {
            // System.out.println(d);
            if (d.containsKey(-A[i] - mask)) {
                ans += d.get(-A[i] - mask);
            }
            if (A[i] == 0) {
                ans++;
            }
            mask += A[i];
            long n = A[i] - mask;
            if (d.containsKey(n)) {
                d.put(n, d.get(n) + 1);
            } else {
                d.put(n, 1);
            }
            // System.out.println(d + " " + mask);      

        }

        pw.println(ans);
        
        pw.close(); 
        br.close();
    }
}

class Point implements Comparable<Point>{
    public int x, y;
 
    Point(int _x, int _y){
        x = _x;
        y = _y;
    }
 
    public String toString(){
        return x + " " + y;
    }

    public int compareTo(Point p){
        if (x != p.x) return x < p.x ? -1 : 1;
        if (y != p.y) return y < p.y ? -1 : 1;
        return 0;
    }
} 


Measured memory_bytes: 56848
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007ll
using namespace std;
ll mem[1000006][2][2], n;
ll dp(int pos, bool f1, bool f2)
{
    if(pos==n)return (f1 && f2);
    if(mem[pos][f1][f2]!=-1)return mem[pos][f1][f2];
    mem[pos][f1][f2]= 0;
    for(int i=0; i<10; i++)
    mem[pos][f1][f2]+= dp(pos+1, f1|(i==0), f2|(i==9)), mem[pos][f1][f2]%= mod;
    return mem[pos][f1][f2];
}
int main()
{
    scanf("%lld", &n);
    memset(mem, -1, sizeof mem);
    printf("%lld\n", dp(0, 0, 0));
    return 0;
}


Measured memory_bytes: 97316
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<map>
#include<queue>
#include<set>
#include<bitset>
#include<stdio.h>
#include<deque>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
 
int main()
{
   int a, b, c;
   cin >> a >> b >> c;
   int m = max(a, max(b, c));
   cout << a+b+c+(m*9) << endl;
   return 0;
}

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

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

using namespace std;
typedef long long ll;
const int MAXN = 200;

int top = 0;
int S[MAXN];

void initialize() {
	top = 0;
}

bool isEmpty() {
	if (top == 0)return true;
	else false;
}

void push(int x) {
	S[top + 1] = x;
	top++;
}

int pop() {
	int ans = S[top];
	top--;
	return ans;
}

int main() {
	char  s[100];
	int a, b;
	while (cin >> s) {
		if (s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		}
		else if (s[0] == '-') {
			a = pop();
			b = pop();
			push(b - a);
		}
		else if (s[0] == '*') {
			a = pop();
			b = pop();
			push(a * b);
		}
		else {
			push(atoi(s));
		}
	}
	cout << pop() << endl;
	return 0;
}


Measured memory_bytes: 3100
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
      
      	String s = sc.next();
      	int nam[] = new int[26];
      
      for(char i=0; i< s.length();i++){
      		nam[s.charAt(i)-97]++;
      }
      
      for(int j = 0; j < 26;j++){
      		if(nam[j]%2!=0){
            	System.out.print("No");
				System.exit(0);
      	}
      }
      	System.out.print("Yes");
    }
}

Measured memory_bytes: 21972
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
    string s;
    cin >> s;
    if ((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
n = int(input())
l = sorted(list(map(int, input().split())))
ans = 0
ed = []
for i in range(n):
    for j in range(i):
        for k in range(j):
            if (l[k] != l[j] and l[i] != l[j] and l[k] + l[j] > l[i]):ans+=1

print(ans)

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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

    int N = S.size();

    vector<vector<ll>> dp(N + 1, vector<ll>(4));
    dp[0][0] = 1;
    rep(i, N) {
        if (S[i] == 'A') {
            dp[i + 1][0] = dp[i][0];
            dp[i + 1][1] = dp[i][0] + dp[i][1];
            dp[i + 1][1] %= MOD;
            dp[i + 1][2] = dp[i][2];
            dp[i + 1][3] = dp[i][3];
        } else if (S[i] == 'B') {
            dp[i + 1][0] = dp[i][0];
            dp[i + 1][1] = dp[i][1];
            dp[i + 1][2] = dp[i][1] + dp[i][2];
            dp[i + 1][2] %= MOD;
            dp[i + 1][3] = dp[i][3];
        } else if (S[i] == 'C') {
            dp[i + 1][0] = dp[i][0];
            dp[i + 1][1] = dp[i][1];
            dp[i + 1][2] = dp[i][2];
            dp[i + 1][3] = dp[i][2] + dp[i][3];
            dp[i + 1][3] %= MOD;
        } else {
            dp[i + 1][0] = dp[i][0] * 3;
            dp[i + 1][0] %= MOD;
            dp[i + 1][1] = dp[i][0] + dp[i][1] * 3;
            dp[i + 1][1] %= MOD;
            dp[i + 1][2] = dp[i][1] + dp[i][2] * 3;
            dp[i + 1][2] %= MOD;
            dp[i + 1][3] = dp[i][2] + dp[i][3] * 3;
            dp[i + 1][3] %= MOD;
        }
    }

    cout << dp[N][3] << endl;
}

Measured memory_bytes: 7424
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 1000010
char s[MAXN],t[MAXN];
int n,p[MAXN],l,ans,x[MAXN],y[MAXN],sl,sr,k;
int main()
{
	scanf("%d%s%s",&n,s+1,t+1);
	char ls=t[n];
	int np=n,flag=1;
	for(int i=1;i<=n;i++)
		if(s[i]!=t[i])
		{
			flag=0;
			break;
		}
	if(flag==1)
	{
		printf("0\n");
		return 0;
	}
	flag=1;
	for(int i=n-1;i>=0;i--)
		if(t[i]!=ls)
		{
			np=min(np,i+1);
			for(;np;np--)
				if(s[np]==ls)
				{
					p[i+1]=np;
					break;
				}
			if(np==0)
			{
				flag=0;
				break;
			}
			ls=t[i];
		}
	if(flag==0)
	{
		printf("-1\n");
		return 0;
	}
	ans=1;
	sl=0,sr=0;
	for(int i=1;i<=n;i++)
	{
		if(p[i]==0) continue;
		if(l>=p[i])
		{
			k++;
			ans=max(ans,y[sl]+k);
			x[sr]=i-k,y[sr++]=2-k;
			l++;
		}
		else if(l<p[i]&&p[i]<i)
		{
			if(ans==1)
			{
				ans=2,l=i;
				x[sr]=i-k,y[sr++]=2-k;
			}
			else if(ans==2)
			{
				sl=sr;
				x[sr]=i-k,y[sr++]=2-k;
				l=i;
			}
			else
			{
				l=p[i];
				k++;
				for(int j=sl;j<sr;j++)
					if(x[sl]+k-1<p[i]) sl++;
					else
					{
						ans=max(ans,y[j]+k);
						break;
					}
				x[sr]=i-k,y[sr++]=2-k;
			}
		}
		else if(l<p[i]&&p[i]==i)
		{
			k=0;
			sl=sr;
			l=i;
		}
	}
	printf("%d\n",ans);
}
/*
15
dqvfqxxbuizsxiw
ddqqvfqqxxxxbuu


*/

Measured memory_bytes: 13824
#include"bits/stdc++.h"

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

using namespace std;

int main(void) {
	int N, M, Q, ans = 0;
	cin >> N >> M >> Q;
	vector<int> a(Q), b(Q), c(Q), d(Q);

	rep(i, Q) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		a[i]--; b[i]--; c[i]; d[i];
	}

	stack<vector<int>> s;
	for(int i = 1;i <= M;i++){
		vector<int> arr(1);
		arr[0] = i;
		s.push(arr);
	}

	while (!s.empty()) {
		vector<int> arr = s.top();
		s.pop();
		if (arr.size() >= N) {
			int score = 0;
			rep(i, Q) {
				if (arr[b[i]] - arr[a[i]] == c[i]) score += d[i];
			}
			ans = max(score, ans);
		}
		else {
			for (int i = arr[arr.size()-1]; i <= M; i++) {
				vector<int> next = arr;
				next.push_back(i);
				s.push(next);
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3596
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las
    
main = do
    (n, k) <- readTuple2
    ns <- readInts
    print . length . filter (>= k) $ ns

Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  unsigned long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
#define  B   begin()
#define  E   end()
const int N=2e5+3;
//string s,p;
//vector<int>v;
//map<int,int>mp;

int main()
{
    ft
    ll t,i,j,n,m,l,r;
    cin>>n>>m;
    l=m;
    r=m;
    int f=0,x=0;
    for(i=1;i<n;i++)
    {
        cin>>m;
        l*=m;
        if(l<r)
        {
            f=1;
        }
        if(m==0)
        {
            x=1;
        }
        r=l;
    }
    if(x==1)
    {
        l=0;
        f=0;
    }
    (f==0 && l<=(ll)(1e18))? cout<<l:cout<<"-1";
    return 0;
}



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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;

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

    set<int> st;
    rep(i, 3) {
        int x;
        cin >> x;
        st.insert(x);
    }
    cout << st.size() << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		String[] tmp = scanner.nextLine().split(" ");
		int l = Integer.parseInt(tmp[0]);
		int r = Integer.parseInt(tmp[1]) + 1;
		int d = Integer.parseInt(tmp[2]);
		int a = 0;


		for(int i = l; i < r; i++) {

			a += i % d == 0 ? 1 : 0;

		}

		System.out.println(a);
	}
}


Measured memory_bytes: 35580
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,x,y,ans;
inline int read()
{
	int num=0,flag=1;
	char c=getchar();
	for (;c<'0'||c>'9';c=getchar())
	if (c=='-') flag=-1;
	for (;c>='0'&&c<='9';c=getchar())
	num=(num<<3)+(num<<1)+c-48;
	return num*flag;
}
int main()
{
	a=read();
	b=read();
	c=read();
	x=read();
	y=read();
	if (x>y)
	{
		swap(a,b);
		swap(x,y);
	}
	if (a+b>=2*c) ans=min(2*c*x+b*(y-x),2*c*y);
	else ans=a*x+b*y;
	printf("%lld\n",ans);
	return 0;
}

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

int main() {
   int h , n ;
   cin >> h >> n;
   int arr [h+1];
   for (int i =0; i < h+1; i++)arr[i]=0;
   vector <pair <int , int >>v;
    for (int i = 0; i < n; i++){
        int c,d; cin >>d>>c;
        v.push_back(make_pair(c,d));
        sort(v.begin(), v.end());
    }
    if (h <= v[0].second){ cout << v[0].first<< endl; return 0;}
    for (int i = 1; i <= v[0].second; i++) { arr[i]= v[0].first; }
    for (int i = v[0].second+1; i <=h; i++){
        int a = 1000000000;
        for (int j = 0; j < v.size(); j++){
            if (v[j].second >=i) a = min(a,v[j].first );
            else  {a= min (a, arr[i-v[j].second]+v[j].first);}
        }
        arr[i]=a;
    }
    cout << arr[h];
}

Measured memory_bytes: 384
object Main {

  import Math.pow

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val N, K = sc.nextInt

    var result: Double = 0.0
    for (i <- 1 to N) {
      var point = i
      var count = 0
      while (point < K) {
        point *= 2
        count += 1
      }
      result += (1.0 / N) * (1 / pow(2.0, count))
    }

    println(result)
  }
}

Measured memory_bytes: 27332
#include<bits/stdc++.h>
typedef long long int ll;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define p push
#define p1 pop
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pi pair<ll,ll>
#define e 1000000007
using namespace std;
ll dp[3005][3005];
ll solve(ll i,ll j,ll arr[])
{
    if(i==j)
        return dp[i][j]=arr[i];
    if(dp[i][j]!=-1)
        return dp[i][j];
    return dp[i][j]=max(arr[i]-solve(i+1,j,arr),arr[j]-solve(i,j-1,arr));
}
int main(){
    ll n;cin>>n;
    ll arr[n];
    for(int i=0;i<n;++i)
        cin>>arr[i];
    memset(dp,-1,sizeof(dp));
   cout<<solve(0,n-1,arr);
    return 0;
}

Measured memory_bytes: 71040
#include <stdio.h>

int main()
{
    int n= 0,x = 0;
    scanf("%d %d",&n,&x);

    int a[n];

    for(int i = 0; i<n ; i++)
    {
        scanf("%d",&a[i]);
    }

    for(int i = 0;i<n;i++)
    {
        for(int j = n-1 ; j>i ; j--)
        {
            if(a[j]<a[j-1]){
                int temp = a[j];
                a[j] = a[j-1];
                a[j-1] = temp;
            }
            
        }
    }

    int count = 0;

    for(int i = 0;x>0;i++)
    {   
        if(a[i] > x || (n == count+1 && x>a[i]))
        {
            break;
        }
        x -= a[i];
        
        
        count++;
    }

    printf("%d\n",count );

    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

struct UnionFindSize {
    vector<int> par;
    
    UnionFindSize(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

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

    ll N, K;
    cin >> N >> K;
    vector<ll> P(N);
    REP(i, N) cin >> P[i];

    vector<ll> tan(N);
    REP(i, N-1){
    	int j = i;
    	while(P[j+1]>=P[j] && j < N-1){
    		j++;
    	}
    	int len = j-i+1;
    	for(int k=i;k<=j;k++) tan[k] = len - (k-i);
    	i = j;
    }
    tan[N-1] = 1;
    //cout << tan << endl;

    UnionFindSize uf(N-K+2);

    set<ll> st;
    bool ok1 = false, ok2 = false;
    bool mae_sorted = false;
    REP(i, K-1) st.insert(P[i]);
    REP(i, N-K+1){
    	ll next = P[K-1+i];
    	ll ma = *(--st.end());
    	st.insert(next);
    	//dump(ma)
    	//dump(next)
    	if(ma < next){
    		ok2 = true;
    	}else{
    		ok2 = false;
    	}

        if(tan[i]>=K) uf.merge(i, N-K+1);
        if(ok1&&ok2&&i>0) uf.merge(i, i-1);

    	ll kieru = P[i];
    	ll mi = *(st.begin());
    	if(mi == kieru){
    		ok1 = true;
    	}else{
    		ok1 = false;
    	}
    	st.erase(kieru);
    	//cerr << endl;
    }
    set<ll> con;
    REP(i, N-K+2) con.insert(uf.root(i));
    ll ho = (uf.size(N-K+1)==1 ? 1 : 0);
    cout << con.size() - ho << endl;
    return 0;
}

Measured memory_bytes: 13568
#include <iostream>
#include <string>

using namespace std;

int H, W, N;
int sr, sc;
string S, T;

int IsRight(void) {

	int pos = sc;

	for (int i = 0; i < N; i++) {
		if (S[i] == 'R') { pos++; }
		if (pos > W) { return 1; }
		if ((T[i] == 'L') && pos >= 2) { pos--; }
	}
	return 0;
}
int IsLeft(void) {

	int pos = sc;

	for (int i = 0; i < N; i++) {
		if (S[i] == 'L') { pos--; }
		if (pos <1) { return 1; }
		if ((T[i] == 'R') && pos <W ) { pos++; }
	}
	return 0;
}

int IsUp(void) {

	int pos = sr;

	for (int i = 0; i < N; i++) {
		if (S[i] == 'U') { pos--; }
		if (pos <1) { return 1; }
		if ((T[i] == 'D') && pos <H) { pos++; }
	}
	return 0;
}

int IsDown(void) {

	int pos = sr;

	for (int i = 0; i < N; i++) {
		if (S[i] == 'D') { pos++; }
		if (pos >H) { return 1; }
		if ((T[i] == 'U') && pos >1) { pos--; }
	}
	return 0;
}

int main(void) {

	cin >> H >> W >> N;
	cin >> sr >> sc;

	cin >> S >> T;

	int flag = 1;

	if (IsRight() == 1) { flag = 0; }
	if (IsLeft() == 1) { flag = 0; }
	if (IsUp() == 1) { flag = 0; }
	if (IsDown() == 1) { flag = 0; }

	if (flag == 1) { cout << "YES" << endl; }
	else { cout << "NO" << endl; }

	return 0;
}

Measured memory_bytes: 776
#include<stdio.h>
 #include<stdbool.h>
#define N 8
#define FREE -1
#define NOT_FREE 1
 
 int row[N],col[N],dpos[2*N-1],dneg[2*N-1];
bool X[N][N];
 
void initialize(){
  int i;
  for(i=0;i<N;i++){
    row[i]=FREE,col[i]=FREE;
  }
}
 
void printBoard(){
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(X[i][j]){
    if(row[i]!=j)return;
      }
    }
  }
  for( i=0;i<N;i++){
    for(j=0;j<N;j++){
      printf((row[i]==j)?"Q":".");
    }
    printf("\n");
  }
}
 
 void recursive(int i){
   int j;
   if(i==N){
     printBoard();
     return;
   }
   for(j=0;j<N;j++){
     if(NOT_FREE==col[j] ||NOT_FREE==dpos[i+j] || NOT_FREE==dneg[i-j+N-1] )continue;
 
     row[i]=j;
     col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
 
     recursive(i+1);
 
     row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
   }
 }
 
 int main(){
   initialize();
   int i,j;
   for(i=0;i<N;i++){
     for(j=0;j<N;j++)X[i][j]=false;
   }
   int k;
   scanf("%d",&k);
   for(i=0;i<k;i++){
     int r,c;
     scanf("%d%d",&r,&c);
     X[r][c]=true;
   }
 
   recursive(0);
   return 0;
 }

Measured memory_bytes: 588
#include <stdio.h>

int main(void)
{
	long long n, m;
	long long ans = 0;
	
	scanf("%lld %lld", &n, &m);
	
	if(2*n <= m)
		ans = n + (m-2*n)/4;
	else
		ans = m/2;
	
	printf("%lld\n", ans);
	
	
	return 0;
}


Measured memory_bytes: 128
program test
implicit none
integer::N,Y,i,j,check
read(*,*)N,Y
check=0
do i=0,N
	do j=0,N-i
    	if(i*10000+j*5000+(N-i-j)*1000==Y)then
    	print*,i,j,(N-i-j)
    	check=1
    	exit
    	end if
    end do
    if(check==1)exit
end do
if(check==0)then
print*,-1,-1,-1
end if
end program

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll N;
ll F[105][15];
ll P[105][15];

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

  cin >> N;
  rep(i,N)rep(j,10)
    cin >> F[i][j];
  
  rep(i,N)rep(j,11)
    cin >> P[i][j];


  ll joi=1;
  ll ans = -2000000000;
  while(joi <=1023){
    ll times = joi;
    ll open[10];
    rep(i,10){
      if((times%2) == 1)open[i]= 1;
      else open[i] = 0;
      times/=2;
    }
    ll same[100]={0};

    ll ret = 0;
    rep(i,N){
      rep(j,10){
	if((open[j]==1)&&(F[i][j]==1)){
	  same[i]++;
	}
      }
      ret += P[i][same[i]];
    }
    ans = max(ans,ret);
    

    joi++;
  }
  
  cout << ans << endl;
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<queue>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
using namespace std;
int main()
{
	char a[101],b[101];
    int max,len1,len2;
    scanf("%s",a);
    scanf("%s",b);
     len1=strlen(a);
     len2=strlen(b);
     if(len1>len2)
	 {
	 	 	printf("GREATER\n");
	 }
	 if(len1<len2)
	 {
      printf("LESS\n");
	 }
	 if(len1==len2){
			max=strcmp(a,b);
			if(max>0){
				printf("GREATER\n");
				}
				if(max==0)
				{
					printf("EQUAL\n");
				}
					if(max<0)
					{
                     printf("LESS\n");
					}
}
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define LAST(vec) vec[vec.size() - 1]
string get_line() {
  string line;
  cin >> line;
  return line;
}
// 整数: 一桁
int main() {
  while (true) {
    auto line_num = stoi(get_line());
    if (line_num == 0) return 0;
    if (line_num == 1) {
      cout << stoi(get_line()) << endl;
      continue;
    }
    vector<int> stack;
    vector<bool> is_adds;
    auto calc = [&](int num) {
      if (LAST(is_adds)) {
        LAST(stack) += num;
      } else {
        LAST(stack) *= num;
      }
    };
    auto reduction = [&](int n) {
      REP(j, n) {
        auto num = LAST(stack);
        is_adds.pop_back();
        stack.pop_back();
        calc(num);
      }
    };

    REP(i, line_num) {
      auto line = get_line();
      auto level = line.size() - 1;
      // リダクション
      if (level < stack.size()) {
        auto n = stack.size() - level;
        reduction(n);
      }
      // パース
      auto chr = line[line.size() - 1];
      if (chr == '+') {
        stack.push_back(0);
        is_adds.push_back(true);
      } else if (chr == '*') {
        stack.push_back(1);
        is_adds.push_back(false);
      } else {
        calc(chr - '0');
      }
    }
    if (stack.size() > 1) {
      reduction(stack.size() - 1);
    }
    cout << LAST(stack) << endl;
  }
}



Measured memory_bytes: 3172
#pragma GCC optimize("Ofast")
#include <queue>
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
int d; 
int main()
{
	fast;
	cin>>d;
	if (d==25)
	   cout<<"Christmas\n";
	else if (d==24)
	   cout<<"Christmas Eve\n";
	else if (d==23)
	    cout<<"Christmas Eve Eve\n";
	else if (d==22)
	   cout<<"Christmas Eve Eve Eve\n";
    return 0;
}

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

#define times(n, i) uptil(0, n, i)
#define upto(f, t, i) for(auto _##i = (t), i = decltype(_##i)(f) poi  i <= _##i poi  i++)
#define uptil(f, t, i) for(auto _##i = (t), i = decltype(_##i)(f) poi  i < _##i poi  i++)
#define downto(f, t, i) for(auto i = (f), _##i = decltype(i)(t) poi  i >= _##i poi  i--)
#define downtil(f, t, i) for(auto i = (f), _##i = decltype(i)(t) poi  i > _##i poi  i--)

#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define poi ;
#define poipoi << "\n"

using namespace std;

#define fuwafuwa(n, c) dokidoki((n) + (c) - 1, c)
#define dokidoki(n, c) ((n) / (c) * (c))

template<class T> bool read(T& t){
    return cin >> t poi
}
template<class T, class...U> bool read(T& t, U&... u){
    unless(cin >> t) return false poi
    return read(u...) poi
}

template<class T> T lov_yet(T t){
    if(t) return t poi
    else return 0 poi
}

template<class T> T gcd(T a, T b){
    if(b) return gcd(b, a % b) poi
    else return a poi
}

pair<double, double> solve_linear(double a1, double b1, double c1, double a2, double b2, double c2){
    return make_pair(lov_yet((b1 * c2 - b2 * c1) / (b1 * a2 - b2 * a1)), lov_yet((a1 * c2 - a2 * c1) / (a1 * b2 - b1 * a2))) poi
}

double distance(const pair<double, double>& p){
    return lov_yet(sqrt(p.first * p.first + p.second * p.second)) poi
}
double distance(const pair<double, double>& a, const pair<double, double>& b){
    return distance(make_pair(a.first - b.first, a.second - b.second)) poi
}

int main(){
    int n poi
    cin >> n poi
    double x1, y1, x2, y2, x3, y3 poi
    times(n, i){
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 poi
        // 2 * (x1 - x2) * px + 2 * (y1 - y2) * py = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2
        auto p = solve_linear(2 * (x1 - x2), 2 * (y1 - y2), x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2,
                              2 * (x1 - x3), 2 * (y1 - y3), x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3) poi
        printf("%.3f %.3f %.3f\n", p.first, p.second, distance(make_pair(x1, y1), p)) poi
    }

    return 0 poi
}

Measured memory_bytes: 1236
#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() {
  string s;
  cin >> s;
  int res = 0;
  rep(i, 4){
    if(s[i] == '+'){
      ++res;
    }else{
      --res;
    }
  }

  cout << res << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {

            Solve();

            //Console.WriteLine(ans);
            Console.ReadKey();
        }

        static void Solve()
        {
            long ans;
            var cin = GetLongArray().OrderBy(c=>c).ToArray();
            if (cin[0] == 1)
            {
                if (cin[1] == 1)
                {
                    ans = 1;
                }
                else
                {
                    ans = cin[1] - 2;
                }
            }
            else
            {
                ans = (cin[0] - 2) * (cin[1] - 2);
            }



            Console.WriteLine(ans);
        }


        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
	string input;
  	cin >> input;
  	if (input.size() % 2 != 0) cout << "No" << endl;
  	else {
      	bool isHitaichi = true;
		for (int i = 0; i < input.size(); i += 2) {
			if (input[i] != 'h' or input[i + 1] != 'i'){
              	isHitaichi = false;
              	break;
            }
        }
      	cout << (isHitaichi ? "Yes" : "No") << endl;
    }
  	return 0;
}

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

int main(){
	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif

	int a, b;
	cin >> a >> b;
	cout << a * b;

	return 0;
}

Measured memory_bytes: 3612
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define loop(i,n) for(int i = 0;i < (n);i++)
#define all(A) A.begin(),A.end()
#define pb push_back
#define mp make_pair
#define sz(A) ((int)A.size())
typedef std::vector<int> vi;
typedef std::pair<int,int> pi;
typedef std::vector<pi> vp;
typedef long long ll;
#define popcnt(x) __builtin_popcount(x)
#define LSOne(x) ((x) & (-(x)))
#define print(A,t) cerr << #A << ": "; copy(all(A),ostream_iterator<t>(cerr," " )); cerr << endl
#define prArr(A,n,t)  cerr << #A << ": "; copy(A,A + n,ostream_iterator<t>(cerr," " )); cerr << endl
#define PRESTDIO() cin.tie(0),cerr.tie(0),ios_base::sync_with_stdio(0)
#define what_is(x) cerr << #x << " is " << x << endl
#define bit_lg(x) (assert(x > 0),__builtin_ffsll(x) - 1)
const double PI = acos(-1);
template<class A,class B>
std::ostream& operator << (std::ostream& st,const std::pair<A,B> p) {
	st << "(" << p.first << ", " << p.second << ")";
	return st;
}
using namespace std;

const int MAX = 3 << 10, mod = 998244353;
int dp[MAX][MAX];
int A[MAX], N, S;

int add(int a, int b){
	a += b;
	if(a >= mod) a -= mod;
	if(a < 0) a += mod;
	return a;
}
int mul(int a, int b){
	return (a*(ll)b)%mod;
}

int solve(int n, int s){
	if(s < 0) return 0;
	if(n == -1) return s == 0;
	int & ret = dp[n][s];
	if(ret != -1) return ret;
	return ret = add(mul(2, solve(n-1, s)), solve(n-1, s-A[n]));
}



int main(){
#ifdef HOME
	freopen("in.in", "r", stdin);
#endif
	scanf("%d %d", &N, &S);
	loop(i, N) scanf("%d", A + i);
	memset(dp, -1, sizeof dp);
	cout << solve(N-1, S) << endl;
	return 0;
}


Measured memory_bytes: 40772
#include <stdio.h>
#include <string.h>

int human_num;
int koisi_num[50];
int wan_num;
int wan_pos;

int main(void) {
	int start_wan_num;
	while(1) {
		scanf("%d%d",&human_num,&start_wan_num);
		if(human_num==0 && start_wan_num==0)break;
		memset(koisi_num,0,sizeof(koisi_num));
		wan_num=start_wan_num;
		wan_pos=0;
		while(1) {
			if(wan_num<=0) {
				wan_num=koisi_num[wan_pos];
				koisi_num[wan_pos]=0;
			} else {
				koisi_num[wan_pos]++;
				wan_num--;
				if(wan_num<=0 && koisi_num[wan_pos]==start_wan_num) {
					break;
				}
			}
			wan_pos++;
			if(wan_pos>=human_num)wan_pos=0;
		}
		printf("%d\n",wan_pos);
	}
	return 0;
}

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

using namespace std;

int main() {
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int s1 = h1 * 60 + m1;
    int s2 = h2 * 60 + m2;
    int ans;
    if (s2 >= s1) {
        ans = s2 - s1 - k;
    } else {
        ans = 24 * 60 + s2 - s1 - k;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3596
#include<stdio.h>
int main(void)
{
    int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	
	if(x>=W || x<=0){
		printf("No\n");
	}else if(y>=H || y<=0){
		printf("No\n");
	}else if((x+r)>W || (x+r)<0){
		printf("No\n");
	}else if((y+r)>H || (y+r)<0){
		printf("No\n");
	}else{
		printf("Yes\n");
	}
    return 0;
}

Measured memory_bytes: 584
#include <stdio.h>

long p(long n){
	long A=(n+3)*(n+2)*(n+1)/6;
	
	if(n<=1000){
		return A;
	}else{
	int N=n-999;
	long B=N*(N+1)*(N-1)*2/3;
	return A-B;
	}
}

int main(void){
	long s=1;
	while(scanf("%ld",&s)>0){
      if(s==0)break;
	  if(s>=2000)s=(4000-s);
		printf("%ld\n",p(s));
	}
	return 0;
}


Measured memory_bytes: 2100
#include <iostream>
#include <limits>

int main() {
    int num{}, n{}, min{std::numeric_limits<int>::max()}, max{std::numeric_limits<int>::min()};
    long sum{};
    std::cin >> num;

    for(auto i=0; i<num; i++) {
        std::cin >> n;
        min = (n < min) ? n : min;
        max = (n > max) ? n : max;
        sum += n;
    }
    std::cout << min << " " << max << " " << sum << std::endl;
}



Measured memory_bytes: 3116
fun main(args: Array<String>) {
    val s = readLine()!!.map { c -> c - '0' }
    var result = 0L
    for (i in 0 until (1 shl s.size - 1)) {
        var n = s[0].toLong()
        for (j in 0 until s.size - 1) {
            if ((i shr j) and 1 == 1) {
                result += n
                n = 0
            }
            n = 10 * n + s[j + 1]
        }
        result += n
    }
    println(result)
}


Measured memory_bytes: 33544
#include <stdio.h>
#include <ctype.h>

int main(){
	int i;
	char str;
	while(1){
		str = getchar();
		if(str == '\n') break;
		if(str >= 'a' && str <= 'z') str -= 32;
		printf("%c",str);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 900
//人正是因为度过了一段阴暗岁月，才会更渴求黎明的曙光
//青春不能回头。所以青春也没有终点。
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <memory.h>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;

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

const int MAXN = 0;

int main(void) {
	string s;
	cin >> s;
	if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}




Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
#include <iomanip>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
//template< typename T >
//T mod_pow(T x, T n, const T &p) {
//  T ret = 1;
//  while(n > 0) {
//    if(n & 1) (ret *= x) %= p;
//    (x *= x) %= p;
//    n >>= 1;
//  }
//  return ret;
//}
/////////////////// 
//

#define mod 1000000007LL
#define INF 10000000000000000LL
 
#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 (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
#define mp make_pair
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
//
//
//

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll n,a,b;
  cin >> n >> a >> b;
  cout << min(a,b) << " " << max(0ll,a+b-n) ;
}







Measured memory_bytes: 256