akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = list(map(int, input().split()))
a.sort()
M = max(a)
a.remove(M)
for i in range(n - 1):
    if a[i] > M / 2:
        if a[i] - M / 2 <= M / 2 - a[i - 1]:
            print(M, a[i])
            break
        else:
            print(M, a[i - 1])
            break
else:
    print(M, a[-1])

Measured memory_bytes: 14052
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 1e9+7 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,-1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) << endl ; }
ll gcd(ll a,ll b){if(b==0) return a ; return gcd(b,a%b) ; }
ll lcm(ll a,ll b){return a/gcd(a,b)*b ; }
void chmax(ll &a,ll b){if(a<b) a = b ; }
void chmin(ll &a,ll b){if(a>b) a = b ; }


int main(){
	string t ; cin >> t ;
	for(int i=0;i<t.size();i++){
		if(t.at(i)=='?') cout << 'D' ;
		else cout << t.at(i) ;
	}
	cout << endl ;
}




Measured memory_bytes: 3760
import java.util.*;
public class Main{

	public static void main(String[] args) {
		int i1, i2;
		Scanner sc = new Scanner(System.in);
		i1 = sc.nextInt();
		i2 = sc.nextInt();
		if(i1 > i2)
			System.out.println("a > b");
		else if(i1 < i2)
			System.out.println("a < b");
		else
			System.out.println("a == b");
	}
}

Measured memory_bytes: 17160
intLine()=map(x->parse(Int,x),split(readline()))
w,h,n=intLine()
m=ones(Int,w,h)
for i=1:n
    x,y,a=intLine()
    a==1&&(m[1:x,:]=0)
    a==2&&(m[x+1:w,:]=0)
    a==3&&(m[:,1:y]=0)
    a==4&&(m[:,y+1:h]=0)
end
show(sum(m))

Measured memory_bytes: 169280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  string s,t;
  ll q;
  cin >> s >> t >> q;
  vec ss(s.size()+1);
  vec st(t.size()+1);
  for(ll i=0;i<s.size();i++) {
    ss[i+1]=ss[i]+(s[i]=='A');
  }
  for(ll i=0;i<t.size();i++) {
    st[i+1]=st[i]+(t[i]=='A');
  }
  while(q--) {
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ns=ss[b]-ss[a-1];
    ns=(ns%3+2*(b-a+1-ns)%3)%3;
    ll nt=st[d]-st[c-1];
    nt=(nt%3+2*(d-c+1-nt)%3)%3;
    if(ns==nt) {
      cout << "YES" << endl;
    }
    else {
      cout << "NO" << endl;
    }
  }
}

Measured memory_bytes: 2432
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main() {
	int A, P;
	cin >> A >> P;

	cout << (A * 3 + P) / 2 << endl;

}

Measured memory_bytes: 3600
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
	int k,a,b;
	int i;
	int flag=0;

	scanf("%d",&k);
	scanf("%d %d",&a,&b);
	for(i=a;i<=b;i++){
		if(i%k==0){
			printf("OK");
			flag=1;
			break;
		}
	}
	if(!flag){
		printf("NG");
	}
	return 0;
}

Measured memory_bytes: 1728
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
typedef long long LL;
const int N = 100003;
int n, m, cnt[3], ecnt, dis[N];
LL ans;
bool flag;
vector<int> E[N], Er[N];
inline void dfs(int x){
	++ cnt[dis[x]];
	for(Rint v : E[x]){
		++ ecnt;
		if(dis[v] == -1){
			dis[v] = (dis[x] + 1) % 3; dfs(v);
		} else if(dis[v] != (dis[x] + 1) % 3) flag = true;
	}
	for(Rint v : Er[x])
		if(dis[v] == -1){
			dis[v] = (dis[x] + 2) % 3; dfs(v);
		} else if(dis[v] != (dis[x] + 2) % 3) flag = true;
}
int main(){
	scanf("%d%d", &n, &m);
	memset(dis, -1, sizeof dis);
	for(Rint i = 1;i <= m;i ++){
		int a, b;
		scanf("%d%d", &a, &b);
		E[a].push_back(b);
		Er[b].push_back(a);
	}
	for(Rint i = 1;i <= n;i ++) if(dis[i] == -1){
		dis[i] = flag = cnt[0] = cnt[1] = cnt[2] = ecnt = 0; dfs(i);
		if(flag) ans += (LL) (cnt[0] + cnt[1] + cnt[2]) * (cnt[0] + cnt[1] + cnt[2]);
		else if(!cnt[1] || !cnt[2]) ans += ecnt;
		else ans += (LL) cnt[0] * cnt[1] + (LL) cnt[1] * cnt[2] + (LL) cnt[2] * cnt[0];
	}
	printf("%lld", ans);
}

Measured memory_bytes: 19856
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

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

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

	int len = (int)s.size();

	REP(i, len){
		if (!(i % 2)) cout << s[i];
	}

	cout << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
#include <deque>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    cin >> N;
    N++;
    int A, B;
    vector<int> ops;
    while(N != 1){
        if(N % 2 == 1){
            ops.push_back(0);
            N--;
        }else{
            N >>= 1;
            ops.push_back(1);
        }
    }
    reverse(ops.begin(), ops.end());

    int cnt = 1;
    deque<int> ans1, ans2;
    for(auto op : ops){
        if(op == 0){
            ans1.push_back(cnt);
            ans2.push_front(cnt);
        }else{
            ans1.push_back(cnt);
            ans2.push_back(cnt);
        }
        cnt++;
    }
    vector<int> ans;
    for(auto x : ans1) ans.push_back(x);
    for(auto x : ans2) ans.push_back(x);
    cout << ans.size() << endl;
    for(auto x : ans) cout << x << " ";
    cout << endl;

    //int num = 0;
    //for(int i=1; i<(1<<ans.size()); i++){
    //    vector<int> v;
    //    for(int j=0; j<ans.size(); j++)
    //        if(i & (1<<j)) v.push_back(ans[j]);
    //    if(v.size() % 2 == 1) continue;
    //    bool flag = true;
    //    for(int j=0; j<v.size()/2; j++)
    //        if(v[j] != v[v.size()/2+j]){
    //            flag = false;
    //            break;
    //        }
    //    if(flag)
    //        num++;
    //}
    //cout << num << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);
const std::string yes = "Yes";
const std::string no  = "No";

int main(){
    fast_io();

    int n; ll k; std::cin >> n >> k;
    std::vector<std::pair<ll,ll>> ab(n);
    rep(i,n) std::cin >> ab[i].first >> ab[i].second;

    std::sort(ab.begin(),ab.end());

    for(auto abi:ab){
        k -= abi.second;
        if(k<1){
            std::cout << abi.first << "\n";
            return 0;
        }
    }
}


Measured memory_bytes: 4768
import scala.io.StdIn.{readLine}

object Main extends App {
  def isPalindromic(s: String): Boolean = {
    s(0) == s(4) && s(1) == s(3)
  }

  def nPalindromic(input: String): Int = {
    val ints = input.split(" ").map(_.toInt)
    nPalindromic(ints(0), ints(1))
  }

  def nPalindromic(start: Int, end: Int):Int = {
    (start to end).count(i => isPalindromic(i.toString))
  }

  println(nPalindromic(readLine()))
}

Measured memory_bytes: 35376
#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 rusha scanf("%d",&n);rep(i,1,n)scanf("%d",&a[i]);
#define rushb scanf("%d",&t);while(t--)
#define debug(x) cout<<" L-B-W-- "<<x<<" --N-B\n"
#define pb push_back
#define pii pair<int,int>
#define vii vector<int>
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof a)
#define all(x) (x.begin(),x.end())
#define judgef printf("%s\n",f?"Yes":"No")
#define Judgef printf("%s\n",f?"YES":"NO")
#define sz(x) ((int)(x).size())
#define sf(x) (sizeof(x))
using namespace std;
typedef long long ll;
typedef double db;
const double pai = acos(-1.0);
const double eps = 1e-8;
const int mod=998244353;
//const int mod=1e9+7;
const int inf=1e9+7;
//const ll inf=0x7f7f7f7f1234abcd;
const int maxn=2e5+10;
inline ll ksm(ll x,ll y){ll res=1;while(y){if(y&1)res=res*x%mod;x=x*x%mod;y>>=1;}return res;}
inline ll inv(ll a,ll p){if(a==1)return 1;return (p-p/a)*inv(p%a,p)%p;}
inline ll lcm(ll a,ll b){return a * b / __gcd(a, b);}
int t,n,m,k;
int main(){
    int a,b,c,d,s=0;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    s+=max(min(a,d),0);
    d-=a+b;
    s-=max(min(c,d),0);
    printf("%d\n",s);
    return 0;
}


Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
#define double long double
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100000000;
typedef pair<int,int> P;

int n;
string s;
vector<int>a,b,c;
vector<vector<int>>h,k;
int x,y,z;

int main(void){
    cin>>s;
    int len=s.length();
    if(s[len-1]=='2'||s[len-1]=='4'||s[len-1]=='5'||s[len-1]=='7'||s[len-1]=='9') cout<<"hon"<<endl;
    else if(s[len-1]=='0'||s[len-1]=='1'||s[len-1]=='6'||s[len-1]=='8') cout<<"pon"<<endl;
    else if(s[len-1]=='3') cout<<"bon"<<endl;

}


Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	string s,t;
	cin>>s>>t;
	int c1=0,c2=0;
	while(c1!=s.size()){
		if(isdigit(s[c1])){
			int a=0,b=0;
			while(isdigit(s[c1])){
				a*=10;a+=s[c1]-'0';
				c1++;
			}
			while(isdigit(t[c2])){
				b*=10;b+=t[c2]-'0';
				c2++;
			}
			cout<<a+b;
		}else if(s[c1]==t[c2]){
			cout<<s[c1];
			c1++;c2++;
		}else if(s[c1]=='('){
			int co=0;
			int cnt=0;
			while(cnt!=4){
				if(isdigit(s[c1])){
					c1++;
					continue;
				}
				if(s[c1]=='(')co++;
				else if(s[c1]==')')co--;
				if(co==0)cnt++;
				c1++;
			}
		}else{
			int co=0;
			int cnt=0;
			while(cnt!=4){
				if(isdigit(t[c2])){
					c2++;
					continue;
				}
				if(t[c2]=='(')co++;
				else if(t[c2]==')')co--;
				if(co==0)cnt++;
				c2++;
			}
		}
	}
	cout<<endl;
}

Measured memory_bytes: 3208
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;

int main(void){
    ll r, d, x;
    cin >> r >> d >> x;
    
    for (int i = 0; i < 10; i++) {
        cout << r * x - d << endl;
        x = r*x - d;
    }
    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
#include <queue>
using namespace std;


int main(){
    long long n, r = 0, g = 0, b = 0;
    string s;
    cin >> n >> s;
    for(int i = 0; i < n; ++i){
        if(s[i] == 'R') r++;
        if(s[i] == 'G') g++;
        if(s[i] == 'B') b++;
    }
    long long c = r * g * b;
    for(int i = 0; i < n; ++i)
        for(int j = i + 1; j < n; ++j){
            long long in = 2 * j - i;
            if(in >= n) continue;
            if(s[i] != s[j] && s[j] != s[in] && s[in] != s[i]) c--;
        }
    cout << c;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>

#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif



static void A_task();

int main()
{
	A_task();
	
	fflush(stdout);
	return 0;
}

static void A_task()
{
	int N, K;
	char szS[60] = { 0 };

	scanf(" %d %d", &N, &K);
	scanf(" %s", szS);

	szS[K - 1] = tolower(szS[K - 1]);

	printf("%s\n", szS);
}


Measured memory_bytes: 256
using System;


namespace hello_world
{
	class Program
	{

		static void Main(string[] args)
		{
			
			string[] s = Console.ReadLine().Split(" ");
			int x = int.Parse(s[0]);
			int y = int.Parse(s[1]);
			int z = int.Parse(s[2]);
			Console.WriteLine("{0} {1} {2}", z, x, y);


		}
	}
}




Measured memory_bytes: 27480
// Last Change: 04/06/2019 21:04:54.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  vector<ll> antena(5);
  for (int i = 0; i < 5; ++i) {
    cin >> antena[i];
  }

  sort(antena.begin(), antena.end());

  ll k;
  cin >> k;

  if (antena[4] - antena[0] <= k) {
    cout << "Yay!" << endl;
  } else {
    cout << ":(" << endl;
  }

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int Read()
{
	int f=1,num=0;
	char ch=getchar();
	while(0==isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(0!=isdigit(ch)) num=(num<<1)+(num<<3)+ch-'0',ch=getchar();
	return num*f;
}
string s;

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>s;
	cout<<s[0]<<s.size()-2<<s[s.size()-1]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=1e9;
const long double eps=1e-9;
const int N=3e5+10;
struct node{
	int x,y;
	bool operator < (const node &rhs) const {
		return x<rhs.x;
	}
}a[N],stl[N],str[N];
int w,h,n,ans;
inline int read(){
	int x=0,flag=1;
	char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')flag=-1,ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x*flag;
}
struct Seg_T{
#define mid ((l+r)>>1)
	int Max[N<<2],Tag[N<<2];
	inline void Push_Down(int o){
		if(Tag[o]){
			Max[o<<1]+=Tag[o],Max[o<<1|1]+=Tag[o];
			Tag[o<<1]+=Tag[o],Tag[o<<1|1]+=Tag[o];
			Tag[o]=0;
		}
	}
	void Modify(int o,int l,int r,int L,int R,int val){
		if(L<=l && r<=R){
			Max[o]+=val;Tag[o]+=val;
			return;
		}
		Push_Down(o);
		if(L<=mid)Modify(o<<1,l,mid,L,R,val);
		if(R>mid)Modify(o<<1|1,mid+1,r,L,R,val);
		Max[o]=max(Max[o<<1],Max[o<<1|1]);
	}
}T;
inline void Calc(){
	memset(T.Max,0,sizeof(T.Max)),memset(T.Tag,0,sizeof(T.Tag));
	sort(a+1,a+n+1);
	int i,tpl,tpr;tpl=tpr=0;
	for(i=1;i<=n-1;i++){
		int nex=i-1;
		if(a[i].y<=h/2){
			while(tpl && stl[tpl].y<a[i].y){
				T.Modify(1,1,n,stl[tpl].x,nex,stl[tpl].y-a[i].y);
				nex=stl[tpl].x-1,tpl--;
			}
			if(nex!=i-1)stl[++tpl]=(node){nex+1,a[i].y};
		}
		else{
			while(tpr && str[tpr].y>a[i].y){
				T.Modify(1,1,n,str[tpr].x,nex,a[i].y-str[tpr].y);
				nex=str[tpr].x-1,tpr--;
			}
			if(nex!=i-1)str[++tpr]=(node){nex+1,a[i].y};
		}
		stl[++tpl]=(node){i,0};
		str[++tpr]=(node){i,h};
		T.Modify(1,1,n,i,i,h-a[i].x);
		ans=max(ans,T.Max[1]+a[i+1].x);
	}
}
int main(){
	int i,j,k,m;
	w=read();h=read();n=read();
	for(i=1;i<=n;i++){
		int x=read(),y=read();
		a[i]=(node){x,y};
	}
	a[++n]=(node){0,0},a[++n]=(node){w,h};
	Calc();
	for(i=1;i<=n;i++)swap(a[i].x,a[i].y);swap(w,h);
	Calc();
	printf("%d\n",ans<<1);
	return 0;
}


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

using namespace std;
using ll = long long;

int main() {
	string N;
	cin >> N;
	int sum = 0;
	for (int i = 0; i < N.size(); i++) {
		sum += N[i] - '0';
	}
	if (sum % 9 == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3732
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others

//Hang in there!
//LOVE Nyantako_GG

using namespace std;


int main() {
	int A, B, C;
	cin >> A >> B >> C;
	for (int i = 1; i <= B; i++) {
		if (( A * i ) % B == C) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

int main() {
  ll n,m,k;
  cin>>n>>m>>k;
  vecll a(n);
  for(auto&& e:a) cin>>e;
  sort(ALL(a));
  ll sum = 0;
  ll i;
  for(i = n-1; i >= 0; --i) {
    if (sum + a[i] > m) break;
    sum += a[i];
  }
  if (i < 0) {
    cout<<0<<endl;
    return 0;
  }
  ll rem = m - sum;
  ll lo = -1;
  ll hi = m;
  while (hi-lo > 1) {
    ll mid = (hi + lo) / 2;
    ll cnt_punch = 0;
    ll num = 0;
    REP(j,i) {
      if (a[j] > mid) ++num;
      cnt_punch += max(a[j] - mid, 0l);
    }
    ll fin = max(mid, rem);
    if (a[i] > fin && fin == mid) ++num;
    cnt_punch += max(a[i] - fin, 0l);
    if (cnt_punch - k > num) {
      lo = mid;
    } else {
      hi = mid;
    }
  }
  ll cost = 0;
  //ll num = 0;
  ll cnt_punch = 0;
  REP(j,i) {
    ll mx = min(a[j], hi); 
    cost += mx * (mx+1) / 2;
    //if (a[j] > hi) ++num;
    cnt_punch += max(a[j] - hi, 0l);
  }
  ll fin = max(hi, rem);
  ll mx = min(a[i], fin);
  cost += mx * (mx+1) / 2;
  cost -= rem * (rem+1) / 2;
  //if (a[i] > fin) ++num;
  cnt_punch += max(a[i] - fin, 0l);
  if (cnt_punch > k) {
    cost += (hi+1) * (cnt_punch - k);
  }
  cout<<cost<<endl;
  return 0;
}



Measured memory_bytes: 3640
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

#define COL false
#define ROW true

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

	vector<string> S(2, "");
	cin >> S[0] >> S[1];
	

	long long ret;
	const long long mod = 1E9 + 7;
	bool prev;
	const int d[2] = {1, 2};
	int pos = 0;
	if(S[0][pos] == S[1][pos])
	{
		prev = COL;
		ret = 3;
	}
	else
	{
		prev = ROW;
		ret = 6;
	}
	pos += d[prev];

	for(; pos<N; )
	{
		bool next;
		if(S[0][pos] == S[1][pos])
			next = COL;
		else
			next = ROW;

		if(prev == COL)
				ret *= 2;
		else
		{
			if(next == ROW)
				ret *= 3;
		}
		ret %= mod;

		prev = next;
		pos += d[next];
	}
	
	cout << ret << endl;

	return 0;
}


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

void show( int arr[], size_t size )
{
	cout<<arr[1];
	for( size_t i=2; i<size; i++ ){
		cout<<' '<<arr[i];
	}
	cout<<endl;
}

void bucketSort( int arr[], const size_t arr_s, const int min, const int max )
{
//	size_t cnt_s=max - min +1;
	size_t cnt_s=max+2;
	int *cnt=new int[cnt_s];

	for( size_t i=0; i<cnt_s; i++ ){//
		cnt[i]=0;
	}


	for( size_t i=1; i<arr_s; i++ ){//
		cnt[ arr[i] ]++;
	}


	for( size_t i=1; i<cnt_s; i++ ){
		cnt[i]= cnt[i] + cnt[i-1];
	}

	int *sorted=new int[arr_s];
	for( size_t i=arr_s-1; i>0; i-- ){//
		sorted[ cnt[ arr[i]]]= arr[i];
		cnt[ arr[i] ]--;
		
	}

	show(sorted, arr_s);
	
	/*
	for( size_t i=1; i<arr_s; i++ ){
		arr[i]=sorted[i];
	}
	*/

	

	delete[] cnt;delete[] sorted;

}



int main()
{
	//arr : ???????????????
	size_t arr_s;	cin>>arr_s;arr_s++;
	int *arr=new int[arr_s];

	int max=INT_MIN;
//	int min=INT_MAX;

	for( size_t i=1; i<arr_s; i++ ){
		scanf("%d", &arr[i]);

//		if( arr[i] < min ) min=arr[i];
		if( arr[i] > max ) max=arr[i];
	}



	bucketSort( arr, arr_s, 0, max );
//	show(arr, arr_s);
	
	delete[] arr;


}

Measured memory_bytes: 16768
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <limits>
#include <iomanip>

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

inline int ctoi(char c) {
    return (int)(c -'0');
}

// ----------------------------------------------------------

const static int N = 61;
const static ll MOD = 1000000007;
ll one[N] = {};
ll zero[N] = {};

int main() {
    int n;
    cin >> n;
    vector<ll> arr(n);
    rep(i, n) {
        cin >> arr[i];
    }
    rep(i, n) {
        ll target = arr[i];
        int count = 0;
        while (count < N) {
            int a = target % 2;
            if (a) {
                ++one[count];
            } else {
                ++zero[count];
            }
            ++count;
            target /= 2;
        }
    }
    ll base = 1;
    ll ans = 0;
    rep(i, N) {
        ll temp = base % MOD;
        temp *= zero[i] % MOD;
        temp %= MOD;
        temp *= one[i] % MOD;
        temp %= MOD;
        ans += temp;
        ans %= MOD;
        base *= 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int S, W;
  cin >> S >> W;
  if (S <= W) {
    cout << "unsafe" << endl;
  } else {
    cout << "safe" << endl;
  }
  return 0;
}


Measured memory_bytes: 3040
N=int(input())
X=input()
X10=int(X,2)
one=X.count('1')
def popcount(n):
  c=format(n,'b').count('1')
  if c!=0:
    return n%c
  else:
    return 0
def f(n):
  count=0
  while n>0:
    n=popcount(n)
    count+=1
  return count
if one==1:
  e=X10%2
  for i in range(N):
    if X[i]=='0':
      Y=e+pow(2,N-i-1,2)
      print(f(Y)+1)
     
    elif X[i]=='1':
      print(0)
if one==0:
  for i in range(N):
    print(1)
if one>1:
  a=X10%(one-1)
  b=X10%(one+1)
  c=one-1
  d=one+1
  for i in range(N):
    if X[i]=='1':
      Y=(a-pow(2,N-i-1,c))%c
      print(f(Y)+1)
    if X[i]=='0':
      Y=(b+pow(2,N-i-1,d))%d
      print(f(Y)+1)


Measured memory_bytes: 9572
// Library
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

// TYPEDEFS
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

// CONSTANTS
#define SZA 0
#define SZB 0

// MACRO
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
#define ABS(X) (((X) > 0)? (X) : -(X))
#define YN(X) ((X)? "YES" : "NO")
#define SWAP(T, X, Y) {T t; t = X; X = Y; Y = t;}

#define F1 first
#define S2 second
#define PB push_back
#define MP make_pair


// Global Tables

//ull gPreProcess[SZA][SZB];

// Functions

void Print2DVector(vector<vector<int>>& v)
{
    ull i, j; 
    for(i = 0; i < v.size(); i++)
    {
        for(j = 0; j < v[i].size(); j++)
        {
            cout << v[i][j];
            if(j == v[i].size()-1)
            {
                cout << endl;
            }
            else
            {
                cout << " ";
            }
        }
    }
}

void PrintVector(vi& v)
{
    ull i;
    for(i = 0; i < v.size(); i++)
    {
        cout << v[i];
        if(i == v.size()-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PrintArr(int* a, ull N)
{
    ull i;
    for(i = 0; i < N; i++)
    {
        cout << a[i];
        if(i == N-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PreProcessTables()
{
    ull i, j;
    for(i = 0; i < SZA; i++)
    {
        for(j = 0; j < SZB; j++)
        {
            break;
        }
        break;
    }
}

void TC(int t)
{
    ll a, b, c, d, out;
    cin >> a >> b >> c >> d;
    out = MAX(MAX(a*c, b*d), MAX(a*d, b*c));
    cout << out << endl;

    #ifdef DBG
    //PrintArr(A, N);
    #endif

    //cout.setf(ios::fixed, ios::floatfield);
    //cout.precision(4);
    //M_PI;
    //cout << "Case #" << t << ": " << N << endl;
}

// Main

int main(void)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    PreProcessTables();

    int T = 1, t;
    //cin >> T;
    for(t = 1; t <= T; t++)
    {
        TC(t);
    }
    return 0;
}


Measured memory_bytes: 3652
import math
import fractions

K = int(input())
sum = 0

def gcd2(x,y,z):
    return math.gcd(math.gcd(x,y),z)

for i in range(1,K+1):
    for j in range(i,K+1):
        for k in range(j,K+1):
            if (i == j == k):
                sum += gcd2(i,j,k)
            elif i != j and j != k:
                sum += gcd2(i,j,k)*6
            else:
                sum += gcd2(i,j,k)*3



print(sum)


Measured memory_bytes: 10384
using System;

namespace ALDS1_5B
{
    class Program
    {
        static int count = 0;
        static void Merge(long[] array, int left, int mid, int right)
        {
            var n1 = mid - left;
            var n2 = right - mid;

            var l = new long[n1 + 1];
            var r = new long[n2 + 1];

            for (var n = 0; n < n1; n++)
                l[n] = array[left + n];
           
            for (var n = 0; n < n2; n++)
                r[n] = array[mid + n];
            
            l[n1] = 9999999999;
            r[n2] = 9999999999;

            var i = 0;
            var j = 0;

            for (var k = left; k < right; k++)
            {
                count++;
                if (l[i] <= r[j])
                {
                    array[k] = l[i];
                    i++;
                }
                else
                {
                    array[k] = r[j];
                    j++;
                }
            }
        }

        static void MergeSort(long[] array, int left, int right)
        {
            if (left + 1 < right)
            {
                var mid = (left + right) / 2;
                MergeSort(array, left, mid);
                MergeSort(array, mid, right);
                Merge(array, left, mid, right);
            }
        }

        static void Main()
        {
            var len = int.Parse(Console.ReadLine());
            var array = Array.ConvertAll(
                Console.ReadLine().Split(' '),
                e => long.Parse(e)
            );
            MergeSort(array, 0, len);
            Console.WriteLine(string.Join(" ",
                Array.ConvertAll(array, e => e.ToString())
            ) + "\n" + count.ToString());
        }
    }
}


Measured memory_bytes: 96788
#!/usr/bin/env python3
# ????????????????????°???????????°????????????????????\??????????????¢?????´???????????¨??????????§???????
# ?????????http://www.prefield.com/algorithm/geometry/convex_hull.html

import enum


EPS = 1e-10


class PointsRelation(enum.Enum):
    counter_clockwise = 1
    clockwise = 2
    online_back = 3
    on_segment = 4
    online_front = 5


def inner_product(v1, v2):
    return v1.real * v2.real + v1.imag * v2.imag


def outer_product(v1, v2):
    return v1.real * v2.imag - v1.imag * v2.real


def project(a, b):
    return a * inner_product(a, b) / (abs(a) ** 2)


def points_relation(p0, p1, p2):
    v1 = p1 - p0
    v2 = p2 - p0
    op = outer_product(v1, v2)
    if op > EPS:
        return PointsRelation.counter_clockwise
    elif op < -EPS:
        return PointsRelation.clockwise
    elif inner_product(v1, v2) < -EPS:
        return PointsRelation.online_back
    elif abs(v1) < abs(v2):
        return PointsRelation.online_front
    else:
        return PointsRelation.on_segment


def in_place_convex_hull_andrew(ps):
    def judge(p0, p1, p2):
        b = points_relation(p0, p1, p2) != PointsRelation.counter_clockwise
        b &= points_relation(p0, p1, p2) != PointsRelation.online_front
        return b
    if len(ps) < 3:
        return ps
    ps.sort(key=lambda p: p.imag)
    n = len(ps)
    k = 0
    ch = [None for _ in range(2 * n)]
    for i in range(n):
        while k >= 2 and judge(ch[k - 2], ch[k - 1], ps[i]):
            k -= 1
        ch[k] = ps[i]
        k += 1
    t = k + 1
    for i in range(n - 1)[::-1]:
        while k >= t and judge(ch[k - 2], ch[k - 1], ps[i]):
            k -= 1
        ch[k] = ps[i]
        k += 1
    ch = ch[:k - 1]
    return ch


def main():
    while True:
        n = int(input())
        if n == 0:
            return
        ps = [complex(*map(float, input().split(","))) for _ in range(n)]
        ch = in_place_convex_hull_andrew(ps)
        print(n - len(ch))


if __name__ == '__main__':
    main()

Measured memory_bytes: 8024
#include <iostream>

using namespace std;

int main(){
	int A[5];
	int k;

	for (int i = 0; i < 5; i++ ){
		cin >> A[i];
	}
	cin >> k;

	if(A[4]-A[0] <= k)
		cout << "Yay!" << endl;
	else 
		cout << ":(" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define vr(v,n) vector<int> (v)(n)
#define in(name) for(auto &i:name) cin>>i
#define pr(name) for(auto i:name) cout<<i<<" "
#define db(n) cout<<n<<"\n"
#define start_c auto start_clock_time=chrono::high_resolution_clock::now()
#define stop_c auto stop_clock_time=chrono::high_resolution_clock::now()
#define pr_c cout<<"\n"<<chrono::duration_cast<chrono::milliseconds>(stop_clock_time-start_clock_time).count()<<" ms\n"
#define MOD 1000000007
#define pb push_back()
#define srt(v) sort(v.begin(),v.end())
#define test_cases long long test_cases;cin>>test_cases;while(test_cases-->0)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define fr(i,n) for(ll i=0;i<n;i++)
#define all(v) (v).begin(),(v).end()
using namespace std;
int main(){
    int n;
    cin>>n;
    vr(v,n); in(v);
    int cnt=0;
    int min=INT_MAX;
    for(int i=0;i<n;i++){
        if(v[i]<min)
            min=v[i];
        if(v[i]==min)
            cnt++;
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 1152
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);
	int a, b, c, d;
	in >> a >> b >> c >> d;
	out << ((a < c) ? 1 : 0) << endl;

	return 0;
}
#endif


Measured memory_bytes: 256
#include <iostream>

int main(void) {
  using namespace std;
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if(abs(c - a) <= d || (abs(a - b) <= d && abs(b - c) <= d)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
N,P=map(int,input().split())
A=map(int,input().split())
a=1
for i in A:
    if i%2==1:
     a=0
     break
if a==0:
    print(2**(N-1))
else :
    if P==1:
        print(0)
    else : 
        print(2**N)

Measured memory_bytes: 3064
import numpy as np
import collections

n = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

fact = collections.Counter(prime_factorize(n))
# print("f", fact)
can = 0

for a in fact.values():
    a_i = a
    # print("a", a)
    i = 0
    while(a_i >= 0):
        i += 1
        a_i -= i
        # print("i", i)
    can += (i-1)

print(can)

Measured memory_bytes: 27120
N = gets.chomp.to_i
H = gets.chomp.split.map(&:to_i)

success = true
(1..(H.size-1)).each do |i|
  if H[i] > H[i-1]
    H[i] -= 1
    next
  elsif H[i] == H[i-1]
    next
  else  # H[i] < H[i-1]
    success = false
    break
  end
end

if success
  print "Yes"
else
  print "No"
end

Measured memory_bytes: 9604
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int cnt[10];
int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		string S;
		cin >> S;
		if (S == "AC") cnt[0]++;
		else if (S == "WA") cnt[1]++;
		else if (S == "TLE")cnt[2]++;
		else cnt[3]++;
	}
	cout << "AC x " << cnt[0] << endl;
	cout << "WA x " << cnt[1] << endl;
	cout << "TLE x " << cnt[2] << endl;
	cout << "RE x " << cnt[3] << endl;
}


Measured memory_bytes: 3596
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <limits.h>
const long long INF = LLONG_MAX / 2;
#define FOR(i, r, n) for(int i=(r); i<(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ll long long int
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

using namespace std;
ll ans = 0, sum = 0, n, k, t;
string s;

vector<ll> v;

int main() {
	cin >> s;
	if (s.size() == 2) {
		if (s[0] == s[1]) {
			cout << "1 2" << endl;
		}
		else cout << "-1 -1" << endl;
		return 0;
	}
	FOR(i, 1, s.size()-1) {
		if (s[i - 1] == s[i] || s[i] == s[i + 1] || s[i - 1] == s[i + 1]) {
				cout << i << " " << i + 2 << endl;
			return 0;
		}
	}
	cout << "-1 -1" << endl;
}

Measured memory_bytes: 512
//
/*==========================================================*/
/*    Template ver 2017-0720    |    Created by JollyBee    */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
const double EPS=(double)1e-9;
const double PI=(double)acos(-1.0);
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define FOR(i,n) for(int i=0;i<n;i++)
#define REPP(i,l,r,c) for(int i=l;i<=r;i+=c)
#define REP(i,l,r) REPP(i,l,r,1)
#define FORD(i,n) for(int i=n-1;i>=0;i--)
#define REVV(i,l,r,c) for(int i=l;i>=r;i-=c)
#define REV(i,l,r) REVV(i,l,r,1)
//random
int irand(int lo, int hi){
    return (((double)rand())/(RAND_MAX+1.0)) * (hi-lo+1) + lo;
}
//ll to string
string toString(ll x) {
    stringstream ss;
    ss << x;
    return ss.str();
}
//string to ll
ll toNumber(string S) {
    ll ret;
    sscanf(S.c_str(),"%lld",&ret);
    return ret;
}
// std::fill(start, end, value);
// for(auto it: DS){}

const int INF=(int)2e9;
const ll MOD=(ll)1e9+7;
/*==========================================================*/
/*                     END OF TEMPLATE                      */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/

string dat[105];

int main(){
    int n; scanf("%d %*d", &n);
    REP(i,1,n){
        char s[105];
        scanf("%s", s);
        dat[i] = (string)s;
    }
    sort(dat+1, dat+1+n);
    REP(i,1,n) printf("%s", dat[i].c_str()); puts("");
    return 0;
}


Measured memory_bytes: 256
from sys import stdin
import math

n = int(stdin.readline().rstrip())
li = [list(stdin.readline().rstrip().split()) for _ in range(n)]
s = stdin.readline().rstrip()
time = 0
flag = 0
for i in li:
    if s == i[0]:
        flag = 1
        continue
    if flag == 1:
        time += int(i[1])

print(time)
    
    

        


Measured memory_bytes: 3060
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

#include "bits/stdc++.h"

using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
#define endl '\n'
using ll = long long;
#define int ll
using db = long double;
using ii = pair<int, int>;

const int N = 2e5 + 5, LG = 19, MOD = 998244353;
const int SQ =320;
const long double EPS = 1e-7;

int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

  int n;
  cin >> n;

  vector<ll>a(n),b(n);

  f(i,0,n)  cin >> a[i];
  f(i,0,n)  cin >> b[i];

  priority_queue<pair<ll,int>> pq;

  f(i,0,n)pq.emplace(b[i],i);

  ll ans = 0;
  while(pq.size()){

    int i;  ll val;
    tie(val,i)  = pq.top(); pq.pop();

    ll add = b[(i+1)%n] + b[(i+n-1)%n];
    ll mx = max({b[(i+1)%n],b[(i+n-1)%n],a[i]});

    ll diff = (add-1+val-mx) / add;
    ans += diff;
    val -= add * diff;
    b[i]= val;
    if(b[i] > a[i]){
      pq.emplace(b[i],i);
    }
    if(b[i] < a[i]) {
      cout << -1 << "\n"; return 0;
    }

  }

  cout<<ans<<'\n';




  return 0;
}


Measured memory_bytes: 9584
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    N, K = map(int, input().split())
    p = 10**9+7

    # 階乗の事前計算
    a = [None] * (N+1)
    inva = [None] * (N+1)
    a[0] = 1
    
    for i in range(1, N+1):
        a[i] = i * a[i-1] % p
    
    inva[N] = pow(a[N],p-2,p)
    for i in range(N):
        inva[N-i-1] = inva[N-i] * (N-i) % p

    for i in range(1,K+1):
        if N-K < i-1:
            print(0)
            continue
        tmp = ((a[K-1] * inva[K-i]) % p) * inva[i-1] % p
        tmp2 = ((a[N-K+1] * inva[N-K-i+1]) % p) * inva[i] % p
        print(tmp * tmp2 % p)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3828
import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )

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

main :: IO ()
main = do
  as <- readInts
  print $ f as

f :: [Int] -> Int
f as@[a,b,c,x,y]
  | 2*c < a + b = min (2*c*min x y + g a b x y)
                      (2*c*max x y)
  | otherwise   = a*x + b*y
  where
    g a b x y
      | x < y     = (y-x)*b
      | otherwise = (x-y)*a

Measured memory_bytes: 380
n = int(input())
cards = [[ s+' '+str(n) for n in range(1,14)] for s in ['S','H','C','D']]
for _ in range(n):
    egara,num = input().split()
    if egara == "S":
        cards[0][int(num) - 1] = 0
    elif egara == "H":
        cards[1][int(num) - 1] = 0
    elif egara == "C":
        cards[2][int(num) - 1] = 0
    elif egara == "D":
        cards[3][int(num) - 1] = 0
    
for s in cards:
    for n in s:
        if n!=0: print(n)


Measured memory_bytes: 5600
#include<stdio.h>
#include<math.h>
int main()
{

   double a, b,C,area,rad,cir,height;

    scanf("%lf %lf %lf",&a,&b,&C);
     rad=C*M_PI/180.0;
    area=(1/2.0)*a*b*sin(rad);
    cir=a+b+sqrt((a*a)+(b*b)-(2.0*a*b*cos(rad)));
    height=(2.0*area)/a;
    printf("%lf\n%lf\n%lf",area,cir,height);
    return 0;
}



Measured memory_bytes: 2056
package main

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

func main() {
	sc := NewScanner(os.Stdin)
	a := sc.NextInt()
	b := sc.NextInt()
	_ = sc.NextInt()
	fmt.Println(a * b / 2)
}

func lcm(x, y int) int {
	x, y = max(x, y), min(x, y)
	if y == 0 {
		return x
	}
	return lcm(y, x%y)
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

// scanner
type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner(r io.Reader) *Scanner {
	rdr := bufio.NewReaderSize(r, 1024)
	return &Scanner{r: rdr}
}

func (s *Scanner) ReadLine() {
	s.buf = make([]byte, 0)
	for {
		line, isp, err := s.r.ReadLine()
		if err != nil {
			os.Exit(1)
		}
		s.buf = append(s.buf, line...)
		if !isp {
			break
		}
	}
}

func (s *Scanner) NextInt() int {
	i, err := strconv.Atoi(s.Next())
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) NextFloat64() float64 {
	i, err := strconv.ParseFloat(s.Next(), 64)
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) Next() string {
	s.Pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	next := string(s.buf[start:s.p])
	s.p++
	return next
}

func (s *Scanner) Pre() {
	if s.p >= len(s.buf) {
		s.ReadLine()
		s.p = 0
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[105][100010];
int main(){
    int n,W;cin >> n >> W;
    vector<ll> v(n),w(n);
    for(int i=0;i<n;i++) cin >> w[i] >> v[i];
    for(int i=0;i<n;i++){
        for(int j=0;j<=W;j++){
            dp[i+1][j]=max(dp[i][j],dp[i+1][j]);
            if(j-w[i]>=0){
                dp[i+1][j]=max(dp[i+1][j],dp[i][j-w[i]]+v[i]);
            }
        }
    } 
    cout << dp[n][W] << endl;
    return 0;
}

Measured memory_bytes: 79360
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll N, K, L[123], R[123];
ll A[412345], sum[412345];
ll shift = 200000;

int main() {

	cin >> N >> K;
	rep(i, K) cin >> L[i] >> R[i];
	A[shift] = 1;
	sum[shift] = 1;

	rep(i, N - 1) {
		ll c = i + 1;
		rep(i, K) {
			A[shift + c] += sum[shift + c - L[i]] - sum[shift + c - R[i] - 1];
			A[shift + c] %= 998244353;
		}
		sum[shift + c] = sum[shift + c - 1] + A[shift + c];
		sum[shift + c] %= 998244353;
	}


	cout << (A[shift + N - 1] + 998244353) % 998244353 << endl;

	return 0;
}


Measured memory_bytes: 6732
#include<stdio.h>
#include<algorithm>
using namespace std;
#define Maxn 100009
int a[Maxn],red[Maxn],n,m;
int main(){
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;++i) {
		a[i]=1;
		red[i]=0;
	}
	red[1]=1;
	for(int i=1;i<=m;++i) {
		int z,b;
		scanf("%d %d",&z,&b);
		if(red[z]) red[b]=1;
		--a[z];
		++a[b];
		if(!a[z]) red[z]=0;
	}
	int ans=0;
	for(int i=1;i<=n;++i) ans+=red[i];
	printf("%d\n",ans);
	return 0;
}

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


int main(){
   int n,k;
   cin >> n >> k;
   bool dp[n];
   for(int i=0;i<n;i++) dp[i]=false;

   for(int i=0;i<k;i++){
       int d;
       cin >> d;
       for(int t=0;t<d;t++){
           int p;
           cin >>p;
           if(dp[p-1] == false) dp[p-1]=true;
       }
   }

   int cnt=0;
   for(int i=0;i<n;i++){
       if(dp[i] == false) cnt++;
   }

   cout << cnt << endl;
   return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m; cin >> n >> m;
    string in; cin >> in;

    int cur = n;
    vi res = {m};
    while(cur != 0){
        int nxt = -1;
        int kk;
        rep(k, 1 + (m - res.back()), m + 1){
            if(cur - k < 0) break;
            if(in[cur - k] == '0') nxt = cur - k, kk = k;
        }
        if(nxt < 0){
            cout << -1 << endl;
            return 0;
        }
        cur = nxt;
        res.emplace_back(kk);
    }
    reverse(_all(res));

    rep(i, res.size() - 1){
        cout << (i ? " ":"") << res[i];
    }
    cout << endl;

    return 0;
}


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

int compare(const void* a, const void* b)
{
	const int* x = (int*) a;
	const int* y = (int*) b;

	if (*x > *y)
		return 1;
	else if (*x < *y)
		return -1;

	return 0;
}


int main(){
	
	int N;
	cin>>N;
	int arr[N];
	int count = 0;
	for(int i=0; i<N; i++)
	{
		cin>>arr[i];
	}

  	qsort(arr,N,sizeof(int),compare);

    for(int i=0; i<N; i++)
    {
    	int k = i+2;
    	for(int j=(i+1); j<N; j++)
    	{
    		while(k<N && (arr[i]+arr[j] > arr[k]))
    		{
    			k++;
    		}
    		count = count + k - j -1;
    	}
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX]; // 隣接リスト
int color[MAX]; // グループ(色)を表す配列、同じ色なら同じグループ

// 深さ優先探索
void dfs(int r, int c) {
	stack<int> S;
	S.push(r);
	color[r] = c;

	while (!S.empty()) {
		int u = S.top(); S.pop();
		for (int i = 0; i < G[u].size(); i++) { // id別に連結リスト内を辿る
			int v = G[u][i];
			if (color[v] == NIL) { // まだどのグループにも所属してなければ
				color[v] = c;
				S.push(v);
			}
		}
	}
}

void assignColor() {
	int id = 1;
	for (int i = 0; i < n; i++) color[i] = NIL;
	for (int u = 0; u < n; u++) {
		if (color[u] == NIL) dfs(u, id++);
	}
}

int main() {
	int s, t; // 質問用の友人s,t
	int m, q; // 友人の関係がある数ｍ、質問の個数ｑ

	cin >> n >> m; // 頂点の個数n, 友人関係m

	for (int i = 0; i < m; i++) {
		cin >> s >> t;
		G[s].push_back(t);
		G[t].push_back(s);
	}

	assignColor();

	// 以下、質問パート
	cin >> q;

	for (int i = 0; i < q; i++) {
		cin >> s >> t;
		if (color[s] == color[t]) {
			cout << "yes" << endl;
		}
		else {
			cout << "no" << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 8928