akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
int n,d,x[11][11],ans;
signed main(){
	cin>>n>>d;
	rep(i,n){
		rep(j,d){
			cin>>x[i][j];
		}
	}
	rep(i,n){
		for(int j=i+1;j<n;j++){
			int cnt=0;
			rep(k,d){
				cnt+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
			}
			if((int)sqrt(cnt)*(int)sqrt(cnt)==cnt)ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;
const int mod=1000000007;

long long modinv(long long a){
	long long b=mod,u=1,v=0;
  	while(b){
      long long t=a/b;
      a-=t*b;
      swap(a,b);
      u-=t*v;
      swap(u,v);
    }
  	u%=mod;
  	if(u<0) u+=mod;
  	return u;
}

long long dev(long long a,long long b){
	return (a*modinv(b))%mod;
}

long long comb(int x,int y){
  long long tmp=1;
	for(int i=0;i<y;i++){
    	tmp=dev(tmp*(x-i)%mod,i+1);
    }	 
  return tmp;
}

int main(){
	int N,M; cin>>N>>M;
  	int cnt=0;
 	long long ans=1;
  
  for(int i=2;i<=M;i++){
    if(M%i==0){
      while(1){
        if(M%i!=0){
          ans=(ans*comb(cnt+N-1,cnt))%mod;
          cnt=0;
          break;
        }else{
          M/=i;
          cnt++;
        }
      }
    }
  }

	printf("%lld",ans);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define lli unsigned long long int
#include<bits/stdc++.h>
int main(){
  lli n,r,f,k;
  cin>>k;
  n=k;
  
  while(1){
    int b=1;
    if(n==1)
      b=0;
    else if(n<4)
      b=1;
    else if(n%2==0)
      b=0;
    else if(n<9)
      b=1;
    else if(n%3==0)
      b=0;
    else{
      r=sqrt(n);
      f=5;
      while(f<=r){
        if(n%f==0){
          b=0;
          break;
        }
        if(n%(f+2)==0){
          b=0;
          break;
        }
        f=f+6;
      }
    }
    
    if(b==1){
      cout<<n<<"\n";
      break;
    }
    n++;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
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 FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    set<int> st;
    FOR(x,1,n-1){
        if (2 * x == n) continue;
        st.insert(min(x, n - x));
    }
    cout << st.size() << endl;

    return 0;
}


Measured memory_bytes: 23680
let N = Int(readLine()!)!
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let A = input[0], B = input[1]
let P = readLine()!.characters.split(" ").map{Int(String($0))!}
var problems = [0, 0, 0]
for i in P {
  switch i {
  case 1...A:
    problems[0] += 1
  case A+1...B:
    problems[1] += 1
  default:
    problems[2] += 1
  }
}
print(problems.minElement()!)

Measured memory_bytes: 4208
#include <stdio.h>

int main()
{
    int i, n, x;
    
    scanf("%d", &n);
    
    for(i=1; i<=n; ++i){
        x = i;
        if(x%3 == 0){
            printf(" %d", i);
        } else {
            while(x){
                if(x%10 == 3){
                    printf(" %d", i);
                    break;
                }
                x /= 10;
            }
        }
    }
    printf("\n");
    
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=2e3+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll d[MAXn];
int main(){
  IOS();
  ll n,z,w;
  cin >> n >> z >> w;
  REP (i,n) cin >> d[i];

  if (n == 1) cout << abs(d[0]-w) << endl;
  else cout << max(abs(d[n-1]-w),abs(d[n-2]-d[n-1])) << endl;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll odd(ll a){
  if(a%4==1) return 1;
  else return 0;
}

ll f(ll a){
  if(a%2) return odd(a);
  else return a^odd(a-1);
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll a,b; cin>>a>>b;
  cout<<(f(b)^f(a-1))<<endl;
}

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

using namespace std;

struct Room
{
    vector<int> con;
    int sign = -1;
};

int main(void)
{
    int rooms_cnt;
    int ailes_cnt;
    vector<Room> rooms;

    cin >> rooms_cnt >> ailes_cnt;

    rooms.resize(rooms_cnt);

    for(int i = 0; i < ailes_cnt; i++){
        int a, b;
        cin >> a >> b;
        a -= 1;
        b -= 1;

        rooms[a].con.push_back(b);
        rooms[b].con.push_back(a);
    }

    queue<int> search;
    search.push(0);
    bool *found = new bool[rooms_cnt];
    for(int i = 0; i < rooms_cnt; i++){
        found[i] = false;
    }
    found[0] = true;

    while(!search.empty()){
        int searching = search.front();
        search.pop();

        for(auto con : rooms[searching].con){
            if(!found[con]){
                search.push(con);
                found[con] = true;

                rooms[con].sign = searching;
            }
        }
    }

    for(int i = 1; i < rooms_cnt; i++){
        if(rooms[i].sign == -1){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    for(int i = 1; i < rooms_cnt; i++){
        cout << rooms[i].sign + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 10640
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    lli a, b;
    cin>>a>>b;
    if((a+b)%2!=0){ 
        out("IMPOSSIBLE");
    }
    else{ 
        out((a+b)/2);
    }
}

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

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

const int NICO = 25252125;
bool era[NICO];

int main(){
  int n;
  cin>>n;
  REP(i,NICO)era[i]=true;
  era[0]=era[1]=false;
  REP(i,NICO)if(era[i]){
    int j = i+i;
    while(j < NICO){
      era[j] = false;
      j += i;
    }
  }
  int ans = 0;
  REP(i,n+1){
    int p = 2;
    int q = i;
    if(p>n)continue;
    if(era[p] && era[q] && era[p+q])ans++;
  }
  cout<<ans*2<<endl;
  return 0;
}



Measured memory_bytes: 27768
#C - Rectangle Cutting
W,H,x,y = map(int,input().split())
def main(W,H,x,y):
    if x == W/2 and y == H/2:
        ans1 = H*W/2
        ans2 = 1
    else:
        ans1 = H*W/2
        ans2 = 0
    print(ans1,ans2)
main(W,H,x,y)

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

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
#define        optimize    ios_base::sync_with_stdio(false);cin.tie(NULL);
#define        sqr(a)       ((a)*(a))


int main()
{
    ll tst,n,i,j,m,k,d,x,baki,kk,p1,p2;

    cin  >> x >> k >> d;

    n  =  abs(x/d);

    if(n<k)
    {

        p1 = abs(x-(n*d));
        p2 = abs(x+(n*d));
        kk = min(p1,p2);

      //  cout << kk << endl;
        baki = k-n;

        if(baki%2)
        {
            kk = abs(kk-d);
        }

        cout << kk << endl;
    }
    else
    {
        p1 = abs(x-(k*d));
        p2 = abs(x+(k*d));
        cout << min(p1,p2) << endl;
    }
}


Measured memory_bytes: 3632
#include <math.h>
#include <ctype.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
struct omt{omt(){ios::sync_with_stdio(false);cin.tie(0);}}star;

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

    int A[26] = {};
    REP(i, s.size()){
        A[s[i] - 97]++;
    }
    int f = 0;
    REP(i, 26){
        if(A[i] == 0){
            f = 1;
            char ans = 'a' + i;
            cout << ans << endl;
            break;
        }
    }
    if(f == 0) cout << "None" << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod = 1e9 + 7;
const ll mod2 = 1e9 + 9 ;
using namespace std;

void add(int& a , int b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
ll Pow(ll a , ll b){
	if(b == 0) return 1 ;
	ll c = Pow(a , b / 2) ;
	if(b % 2) return (a * ((c * c)% mod )) % mod ;
	return (c * c) % mod ;
}

int main(){
	IOS;
	cout.precision(50) ;
	/*int n ; cin >> n ;string s ;cin >> s ;
	int nb1 = 0 , nb2 = 0;
	int sum1 = 0 , sum2 = 0 ;
	for(int i = 0; i < n / 2 ; i++){
		if(s[i] !='?') sum1 += s[i] - '0' ;
		else nb1++ ;
	}
	for(int i = n / 2; i < n  ; i++){
		if(s[i] !='?') sum2 += s[i] - '0' ;
		else nb2++ ;
	}
	if(sum1 == sum2 && nb1 == nb2) return cout << "Bicarp" << endl , 0 ;
	if((nb1 + nb2) % 2) return cout << "Monocarp" <<"\n" , 0 ;
	if(sum1 >= sum2){
		if(nb1 % 2) {
			if(sum1 + (nb1 / 2 + 1) * 9 > sum2 + 9 * ((nb2 / 2) + 1)) return cout <<  "Monocarp" <<"\n" , 0 ;
			if(sum1 + (nb1 / 2) * 9 > sum2 + 9 * (nb2 / 2)) return cout <<  "Monocarp" <<"\n" , 0 ;
		}
		else if(sum1 + (nb1 / 2) * 9 > sum2 + 9 * ((nb2 / 2))) return cout <<  "Monocarp" <<"\n" , 0 ;
			
		
	}
	if(sum2 >= sum1){
		if(nb1 % 2) {
			if(sum2 + (nb2 / 2 + 1) * 9 > sum1 + 9 * ((nb1 / 2) + 1)) return cout <<  "Monocarp" <<"\n" , 0 ;
			if(sum2 + (nb2 / 2) * 9 > sum1 + 9 * (nb1 / 2)) return cout <<  "Monocarp" <<"\n" , 0 ;
		}
		else if(sum1 + (nb1 / 2) * 9 > sum2 + 9 * ((nb2 / 2))) return cout <<  "Monocarp" <<"\n" , 0 ;
	}
	cout << "Bicarp" << endl ;*/
	int n ,m; cin >> n >> m;vi a(n);for(int i = 0 ; i < n ; i++) cin >> a[i] ;
	priority_queue<ll> pq ;for(int i = 0 ; i< n ; i++) pq.push(a[i]) ;
	while(m){
		ll x = pq.top() ;
		pq.pop() ;
		x /= 2 ;
		m-- ;
		pq.push(x) ;
	}
	ll ans = 0 ;
	while(pq.size()){
		ans += pq.top();pq.pop() ;
	}
	cout << ans << endl ;
	return 0;
}


Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T&a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T&a,T b){if(a>b){a=b;return 1;}return 0;}
const long long MOD = 1000000007;
typedef long long ll;

ll n,k,a;
string s,t;
double p[200005],q[200005];

int main() {
  cin >> n >> k;
  rep(i,n) cin >> a, p[i]=(double)(1+a)/2;
  rep(i,n) q[i+1]=q[i]+p[i];
  double ans=-1;
  for(int i=0;i<=n-k;i++) chmax(ans,q[i+k]-q[i]);
  printf("%.10f\n",ans);
}

Measured memory_bytes: 3328
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt(),b=sc.nextInt();
		int sum = 0;
		for(int i=0;i<=a;i++){
			for(int j=0;j<=a;j++){
				if(b-i-j<=a&&b-i-j>=0)
					sum++;
			}
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

map<ll,ll>a;
int main() {
	ll n;
	cin>>n;
	for(ll i=2;i<=n;i++){
		ll now=i;
		for(ll j=2;j<=now;j++){
			if(now%j==0){
				while(now%j==0){
				a[j]++;
				now=now/j;
				}
				//cout << j<<endl;
			}
		}
	}
	ll c4=0,c2=0,c74=0,c14=0,c24=0;
	for(auto itr =a.begin();itr!=a.end();itr++){
		ll value=itr->second;
		ll key=itr->first;
		if(value>=74){
			c74++;
		}
		 if(value>=24){
			c24++;
		}
		 if(value>=14){
			c14++;
		}
		 if(value>=4){
			c4++;
			//cout << key<<endl;
		}
		 if(value>=2){
			c2++;
		}
	}
	//cout << c4<<" "<<c2<<endl;
	ll ans=0;
	ans+=max(ll(0),c4*(c4-1)/2*(-2+c2));
	ans+=c74;
	ans+=max(ll(0),c24*(c2-1));
	ans+=max(ll(0),c14*(c4-1));
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
import heapq
h=[]

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
h+=p[:x]
h+=q[:y]
heapq.heapify(h)

from collections import deque
r=deque(r)
while True:
    k=heapq.heappop(h)
    m=r.popleft()
    if k>m:
        heapq.heappush(h,k)
        break
    else:
        heapq.heappush(h,m)
    if not h or not r:
        break
print(sum(h))


Measured memory_bytes: 112848
#include<bits/stdc++.h>
     
    using namespace std;
     
    int main(){
      string s,t;
      cin>>s>>t;
      int ans=0;
      for(int i=0;i<3;++i){
        if(s[i]!=t[i])ans++;
      }
      cout<<3-ans<<endl;
      return 0;
    }

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

static void bubbleSort(int *ID, int *A, int N){
	int temp;
	bool flag;
	do{
		flag = false;
		for (int j = N - 1; j >= 1; j--){
			if (A[ID[j]] < A[ID[j - 1]]){
				temp = ID[j];
				ID[j] = ID[j - 1];
				ID[j - 1] = temp;
				flag = true;
			}
		}
	} while (flag);
}

static void selectionSort(int *ID, int *A, int N){
	int minj, temp;
	for (int i = 0; i < N; i++){
		minj = i;
		for (int j = i + 1; j < N; j++){
			if (A[ID[j]] < A[ID[minj]]){
				minj = j;
			}
		}

		if (minj != i){
			temp = ID[i];
			ID[i] = ID[minj];
			ID[minj] = temp;
		}
	}
}

static bool isStable(int *ID_bubble, int *ID_select, int N){
	for (int i = 0; i < N; i++){
		if (ID_bubble[i] != ID_select[i]){
			return false;
		}
	}

	return true;
}

int main(void){
	int N, *A, *ID_bubble,*ID_select;
	char *pic;

	cin >> N;

	A = new int[N];
	pic = new char[N];
	ID_bubble = new int[N];
	ID_select = new int[N];

	for (int i = 0; i < N; i++){
		cin >> pic[i];
		cin >> A[i];

		ID_bubble[i] = i;
		ID_select[i] = i;
	}

	bubbleSort(ID_bubble, A, N);
	selectionSort(ID_select, A, N);

	for (int i = 0; i < N; i++){
		cout << pic[ID_bubble[i]] << A[ID_bubble[i]];
		if (i != N - 1){
			cout << " ";
		}
	}

	cout << "\nStable\n";

	for (int i = 0; i < N; i++){
		cout << pic[ID_select[i]] << A[ID_select[i]];
		if (i != N - 1){
			cout << " ";
		}
	}

	cout << "\n";
	if (isStable(ID_bubble, ID_select, N)){
		cout << "Stable";
	}
	else{
		cout << "Not stable";
	}
	cout << "\n";

	return 0;
}

Measured memory_bytes: 1196
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  ll n, m; cin >> n >> m;
  ll ans = min(n, m / 2);
  n -= ans;
  m -= ans * 2;

  if (m != 0) ans += m / 4;

  outl(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
 
	int main() {
		string s;
		cin>>s;
		int a=0;
		int b=0;
		int c=0;
		int d=0;
		for(int i=0;i<s.size();i++){
			if(s.at(i)=='N')
				a++;
			if(s.at(i)=='S')
				b++;
			if(s.at(i)=='W')
				c++;
			if(s.at(i)=='E')
				d++;
		}
		if(((a==0||b==0)&&a!=b)||((c==0||d==0)&&c!=d))
			cout<<"No";
		else if ((a==b&&a==0)&&((c==0||d==0)&&c!=d)||((c==d&&c==0)&&((a==0||b==0)&&a!=b)))
			cout<<"No";
		else
			cout<<"Yes";
	}


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

signed main() {

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

    int n, m; cin >> n >> m;
    priority_queue<int> q;
    rep(i,n) {int a; cin >> a; q.push(a);}
    rep(i,m) {int a = q.top(); q.pop(); q.push(a/2);}
    long long ans = 0;
    rep(i,n) {ans += q.top(); q.pop();}
    cout << ans << endl;
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define ll long long

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n;cin>>n;
  vector<ll>h(n);
  vector<ll> dp(n+1, INF);
  rep(i,n)cin>>h[i];

  dp[0]=0;
  rep(i, n){
    ll c = h[i];
    dp[i+1] = min<ll>(dp[i+1], dp[i] + abs<ll>(h[i+1] - c));
    dp[i+2] = min<ll>(dp[i+2], dp[i] + abs<ll>(h[i+2] - c));
  }

  cout<<dp[n-1]<<endl;
//rep(i, n+1)cout<<dp[i]<<' ';cout<<endl;


  return 0;
}

Measured memory_bytes: 1792
INF = 1e20

A, B, Q = [int(i) for i in input().split()]
S = [-INF] + [int(input()) for _ in range(A)] + [INF]
T = [-INF] + [int(input()) for _ in range(B)] + [INF]
X = [int(input()) for _ in range(Q)]

from bisect import bisect_left

for x in X:
    s = bisect_left(S, x)
    t = bisect_left(T, x)
    mi = INF
    for ss in [S[s], S[s - 1]]:
        for tt in [T[t], T[t - 1]]:
            mi = min(mi, abs(ss - x) + abs(tt - ss), abs(tt - x) + abs(ss - tt))
    print(mi)


Measured memory_bytes: 17916
N = gets.to_i
A = gets.split.map(&:to_i).sort.reverse

h = Hash.new(0)

A.each do |a|
  h[a] += 1
end

f = 0
a = b = 0

h.each do |k,v|
  
  v = 4 if v > 4
  v = 2 if v == 3
  
  if v % 4 == 0
    f += 2
    if f == 2
      a = b = k
    elsif f == 3
      b = k
    end
  elsif v % 2 == 0
    f += 1
    if f == 1
      a = k
    elsif f == 2
      b = k
    end
  end
  
  break if a !=0  and b != 0
  
end


puts a * b

Measured memory_bytes: 16504
#include<iostream>

using namespace std;

int main() {
	char v[6] = { 'a','e','i','o','u' };
	char c;
	cin >> c;

	int j = 0;
	for (int i = 0; i < 5; i++) {
		if (c == v[i]) {
			j = 1;
			break;
		}
	}
	if (j == 1)cout << "vowel" << endl;
	else cout << "consonant" << endl;

	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

H, W = lr()
S = [list(sr()) for _ in range(H)]
up = np.array([[1 if x == '.' else 0 for x in row] for row in S])
down = up.copy()
right = up.copy()
left = up.copy()
S = up.copy()
for i in range(H-1):
    up[i+1] += up[i]
    up[i+1] *= S[i+1]
for i in range(H-1, 0, -1):
    down[i-1] += down[i]
    down[i-1] *= S[i-1]
for i in range(W-1):
    left[:, i+1] += left[:, i]
    left[:, i+1] *= S[:, i+1]
for i in range(W-1, 0, -1):
    right[:, i-1] += right[:, i]
    right[:, i-1] *= S[:, i-1]

answer = (up + down + left + right).max() - 3
print(answer)


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


int main(){
  int K;
  cin >> K;

  queue<long long> lun;
  for(int i = 1; i <= 9; i++){
    lun.push(i);
  }
  long long ans;
  for(int k = 1; k <= K; k++){
    ans = lun.front();
    long long now = ans;
    lun.pop();
    int last_dig = now % 10;
    if(last_dig >= 1){
      lun.push(now * 10 + last_dig - 1);
    }
    lun.push(now * 10 + last_dig);
    if(last_dig < 9){
      lun.push(now * 10 + last_dig + 1);
    }
  }
  cout << ans << endl;
}
  


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

using namespace std;

int main(void) {
    int a, b, c, d, flag = 0;
    cin >> a >> b >> c >> d;
    while(!((a <= 0) || (c <= 0))){
        //cout << "c = " << c << " a = " << a << endl;
        c = c - b;
        if(c <= 0){
            flag = 1;
        }
        a = a - d;
    }

    if(flag == 1){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


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

#define SORT(v) sort(v.begin(),v.end())
#define si(n) scanf("%d",&n)
#define sii(n,m) scanf("%d %d",&n,&m)
#define sl(n) scanf("%lld",&n)
#define sll(n,m) scanf("%lld %lld",&n,&m)
#define ss(cad) scanf("%s",cad)
#define PB push_back
#define fst first
#define scn second
#define DBG(x) cerr << #x << " = " << (x) << endl; 
#define M 1000000007
#define N_MAX 100010

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vp;

vb cx(100010), cy(100010);
vector<vi> xs(100010), ys(100010);
ll ans;
int solo;
void bfs(int obj)
{
	set<int> lsx, lsy;
	queue<int> x, y;
	x.push(obj);
	lsx.insert(obj);

	while(!x.empty())
	{
		int curr = x.front();
		x.pop();

		if(cx[curr])
			continue;
		cx[curr] = 1;
		for(auto val: xs[curr])
		{
			if(cy[val] == false)
			{
				y.push(val);
				lsy.insert(val);
			}
		}

		while(!y.empty())
		{
			int curr2 = y.front();
			y.pop();

			if(cy[curr2])
				continue;
			cy[curr2] = 1;
			for(auto val: ys[curr2])
			{
				if(cx[val] == false)
				{
					x.push(val);
					lsx.insert(val);
				}
			}
		}
	}

	if(lsy.size() == 1)
		ans += lsx.size();
	else if(lsx.size() == 1)
		ans += lsy.size();
	else
		ans += (ll)lsx.size()*lsy.size();
}

int main()
{
	int n;
	si(n);
	for(int i = 0; i < n; i++)
	{
		int a, b;
		sii(a, b);
		xs[a].push_back(b);
		ys[b].push_back(a);
	}
	ans = 0;
	for(int i = 1; i <= 100000; i++)
		if(cx[i] == false && !xs[i].empty())
		{
			//DBG(i);
			//DBG(ans)
			bfs(i);
			//DBG(ans);
		}
	ans -= n;
	printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 12800
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = int.Parse(Console.ReadLine());
			for (int i = 0; i < n; i++)
			{
				Console.ReadLine();
				var map = new bool[8][];
				for (int j = 0; j < 8; j++)
					map[j] = Console.ReadLine().Select(c => c == '1').ToArray();

				var x = int.Parse(Console.ReadLine());
				var y = int.Parse(Console.ReadLine());
				f(map, x - 1, y - 1);
				Console.WriteLine("Data {0}:", i + 1);
				g(map);
			}
		}

		static void f(bool[][] map, int x, int y)
		{
			if (x < 0 || y < 0 || x >= 8 || y >= 8) return;
			if (map[y][x])
			{
				map[y][x] = false;
				for (int i = -3; i <= 3; i++)
				{
					f(map, x + i, y);
					f(map, x, y + i);
				}
			}
		}

		static void g(bool[][] map)
		{
			for (int x = 0; x < 8; x++)
			{
				Console.WriteLine(new string(map[x].Select(b => b ? '1' : '0').ToArray()));
			}
		}
	}
}

Measured memory_bytes: 5980
/**
 * @Author: yujirotakahashi
 * @Date:   2020-05-17T20:21:41+09:00
 * @Last modified by:   yujirotakahashi
 * @Last modified time: 2020-05-24T01:58:29+09:00
 */

#include<bits/stdc++.h>
using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define Dcout(a) cout << setprecision(20) << a << endl
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
//const ll INF = (1LL << 60);
//const double pi=acos(-1.0);
using ll = long long;
using PAIR = pair<int, int>;
#define debug cout << "line : " << __LINE__ << " debug" << endl
/****** Template of some basic operations *****/
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; }
/**************************************/

/******** User-defined Function *******/
using Graph = vector<vector<int>>;

/**************************************/

/********** Main()  function **********/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n; cin >> n;
  Graph G(n);
  rep(i,n){
      int u,k; cin >> u >> k;
      u--;
      rep(j,k){
          int v; cin >> v;
          v--;
          G[u].push_back(v);
      }
  }

  vector<int> dist(n,-1);
  queue<int> que;
  dist[0] = 0;
  que.push(0);
  while(!que.empty()){
      int v = que.front(); que.pop();
      for(int nv: G[v]){
          if(dist[nv] != -1) continue;
          dist[nv] = dist[v] + 1;
          que.push(nv);
      }
  }

  rep(i,n){
      cout << i+1 << " " << dist[i] << endl;
  }
  return 0;
}
/********  Main() Ends Here *************/



Measured memory_bytes: 3120
#include <iostream>
#include <set>
#include <math.h>
#include <list>
#include <vector>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MAX_N 10005
#define MAX_M 100

int N;
int A[MAX_N];

int main()
{
    int A, B, K;
    cin >> A >> B >> K;
    int i = min(A, B);
    int ans = 0;
    while (ans < K)
    {
        if (A % i == 0 && B % i == 0)
            ans++;
        i--;
    }
    cout << i + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>*/
#include <bits/stdc++.h>

using namespace std;
//using namespace __gnu_pbds;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 1000000007;
double PI = 4*atan(1);
const int SZ = 1<<19;

// we want max value X-L(X)
int N,M, ans; 
map<int,vi> rec;
int mina[SZ], suma[SZ], lazy[SZ]; 
 
void push(int ind, int low, int high) {
	mina[ind] += lazy[ind];
    if (low != high) lazy[2*ind] += lazy[ind], lazy[2*ind+1] += lazy[ind];
    lazy[ind] = 0;
}
 
void pull(int ind) {
    mina[ind] = max(mina[2*ind],mina[2*ind+1]);
}
 
int qmin(int ind, int low, int high, int L, int R) { // queries max not min oops
	push(ind,low,high);
    if (low > R || high < L) return 0;
    if (L <= low && high <= R) return mina[ind];
    return max(qmin(2*ind,low,(low+high)/2,L,R),qmin(2*ind+1,(low+high)/2+1,high,L,R));
}
 
void update(int ind, int low, int high, int L, int R, int inc) { // take account for minimum as well
    push(ind,low,high);
    if (high < L || R < low) return;
    if (L <= low && high <= R) {
        mina[ind] += inc;
        if (low != high) lazy[2*ind] += inc, lazy[2*ind+1] += inc;
        return;
    }
    update(2*ind,low,(low+high)/2,L,R,inc);
    update(2*ind+1,(low+high)/2+1,high,L,R,inc);
    pull(ind);
}

int main() {
	cin >> N >> M; ans = max(0,N-M);
	F0R(i,N) {
		int a,b; cin >> a >> b;
		rec[b].pb(a);
	}
	FOR(i,1,M+1) update(1,1,M,i,i,-(i-1));
	// cout << ans << "\n";
	for (int i = M; i >= 1; --i) {
		for (int a: rec[i+1]) update(1,1,M,a+1,M,1);
		ans = max(ans,qmin(1,1,M,1,i));
		update(1,1,M,1,i-1,-1);
	}
	cout << ans;
}

Measured memory_bytes: 25600
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

int a, b, c, d, e, f;
double maxv = 0;
int ans[2];

int main() {
	cin >> a >> b >> c >> d >> e >> f;
	for (int ia = 0; 100 * a*ia <= f; ia++) {
		int sa = 100 * a*ia;
		for (int ib = 0; sa + 100 * b*ib  <= f; ib++) {
			int sb = 100 * b*ib;
			for (int ic = 0; sa + sb + c*ic <= f; ic++) {
				int sc = c*ic;
				for (int id = 0; sa + sb + sc + d*id <= f; id++) {
					int sd = d*id;
					if (e*(a*ia + b*ib) >= c*ic + d*id) {
						if (maxv <= (double)(sc + sd) / (double)(sa + sb + sc + sd)) {
							maxv = (double)(sc + sd) / (double)(sa + sb + sc + sd);
							ans[0] = sa + sb + sc + sd;
							ans[1] = sc + sd;
						}
					}
				}
			}
		}
	}
	cout << ans[0] << " " << ans[1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxN = 1e3 + 13;
int cnt[maxN], n, ans;
map<char, int> mp;
void solve (int indx, int ch, int cur) {
    if (indx > 5)
	return;
    if (ch == 3) {
	ans += cur;
	return;
    }
    solve(indx + 1, ch, cur);
    solve(indx + 1, ch + 1, cur *= cnt[indx]);
}
    
int32_t main () {
    cin >> n;
    mp['M'] = 0;
    mp['A'] = 1;
    mp['R'] = 2;
    mp['C'] = 3;
    mp['H'] = 4;
    for (int i = 0; i < n; i++) {
	string s;
	cin >> s;
	if (s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H')
	    cnt[mp[s[0]]]++;
    }
    solve(0, 0, 1);
    cout << ans << endl;
}

  


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

using namespace std;

double dist(double a, double b) {
    return sqrt(a*a + b*b);
}

int main() {
    int N, D, res{};
    cin>>N>>D;
    for (int i = 0; i < N; ++ i) {
        long long a, b;
        cin>>a>>b;
        if (dist(a,b) <= D)
            res++;
    }
    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 3616
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int count=0;
		for(int i=0; i<s.length(); i++){
			if(s.charAt(i)=='o'){
				count++;
			}
		}
		if(count+15-s.length()>=8){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int main(){
    // data loader
    string s;
    cin>>s;
    
    //main
    int n=s.length();
    vector<long long> ans;
    int rem_r=0;
    int rem_l=0;
    int rem_ki=0;
    int rem_gu=1;
    ans.push_back(0);
    for(int i=1;i<s.length();i++){
        ans.push_back(0);
        if (s[i]=='R'){
            if (s[i-1]=='L'){
                rem_ki=0;
                rem_gu=0;
                rem_r=i;
                rem_l=i-1;
            }
            if (((i-rem_r)%2)==0){
                rem_gu++;
            }else{
                rem_ki++;
            }
        }else{
            if (s[i-1]=='R'){
                if (((i-rem_r)%2)==0){
                    ans[i]+=rem_ki+1;
                    ans[i-1]+=rem_gu;
                }else{
                    ans[i]+=rem_gu;
                    ans[i-1]+=rem_ki+1;
                }
                rem_r=i-1;
                rem_l=i;
            }else{
                if (((i-rem_l)%2)==0){
                    ans[rem_l]++;
                }else{
                    ans[rem_r]++;
                }
            }
        }
    }
    for (int i=0;i<n;i++){
        cout<<ans[i]<<endl;
    }
}


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

using namespace std;

double A,B,C,D,E,F;
double Ai,Bi;
double max1 = -1,max2 = 1;
 
int main()
{
    cin>>A>>B>>C>>D>>E>>F;
    Ai = A*E; Bi = B*E;
    double t,k,sum;
 
    for(int a = 0;a*A*100<=F;a++)
    for(int b = 0;b*B*100<=F-a*A*100;b++)
    for(int c = 0;c*C<=F-a*A*100-b*B*100;c++)
    for(int d = 0;d*D<=F-a*A*100-b*B*100-c*C;d++)
    {
        t = c*C+d*D;
        sum = A*a*100+B*b*100+t;
        k = Ai*a+Bi*b;
        
        if(k<t||sum>F)continue;
 
        if(sum!=0&&t/sum>max2/max1){
            max1 = sum;
            max2 = t;
        }
    }
    cout<<int(max1)<<" "<<int(max2)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000
#define MAXM 128
typedef long long ll;

int dtime[MAXM][MAXM], dcost[MAXM][MAXM];
int n, m;

int main(void) {
    while (cin >> n >> m && n && m) {
        for (int i = 1; i <= m; i++) {
            for (int j = 1; j <= m; j++) {
                dtime[i][j] = INF;
                dcost[i][j] = INF;
            }
        }
        for (int i = 0; i < n; i++) {
            int a, b, cost, time;
            cin >> a >> b >> cost >> time;
            dtime[a][b] = dtime[b][a] = time;
            dcost[a][b] = dcost[b][a] = cost;
        }
        for (int k = 1; k <= m; k++) {
            for (int i = 1; i <= m; i++) {
                for (int j = 1; j <= m; j++) {
                    dtime[i][j] = min(dtime[i][j], dtime[i][k] + dtime[k][j]);
                    dcost[i][j] = min(dcost[i][j], dcost[i][k] + dcost[k][j]);
                }
            }
        }
        int K;
        cin >> K;
        for (int i = 0; i < K; i++) {
            int p, q, r;
            cin >> p >> q >> r;
            if (r == 0) {
                cout << dcost[p][q] << endl;
            } else {
                cout << dtime[p][q] << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1256
#include <iostream>

using namespace std;

int main(void) {
    int a, b, c;
    int k;
    cin >> a >> b >> c;
    cin >> k;

    while (k > 0) {
        if (a >= b) {
            b *= 2;
        } else if (b >= c) {
            c *= 2;
        }
        k--;
    }
    if (a < b && b < c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (1e10)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);}} premain;

#define N_MAX (100)
int N, K;


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

  //最低のN-1本で、最大の(N-1)*(N-2)/2対。
  //1本加えるごとに、1対減る。よって、
  int M = (N-1)*(N-2)/2 - K + (N-1);
  
  if (M < (N-1)) {
    print(-1);
	return 0;
  }

  print(M);
  REP(i, N-1) {
    print(1, (i+2));
  }
  int s = 2;
  int t = 3;
  REP(i, M - (N-1)) {
    print(s, t);
    t++;
    if (N < t) {
      s++;
      t = s+1;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
int MOD = 1000000007;

int main() {
	double r; cin >> r;
	printf("%f %f\n", r * r * M_PI, r * M_PI * 2);
}

Measured memory_bytes: 1232
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <functional>

int main() {
  size_t n;
  scanf("%zu", &n);

  std::vector<int> ve(n/2), vo(n/2);
  for (size_t i=0; i<n/2; ++i)
    scanf("%d %d", &ve[i], &vo[i]);

  std::map<int, size_t> ce, co;
  for (size_t i=0; i<n/2; ++i) {
    ++ce[ve[i]];
    ++co[vo[i]];
  }

  std::vector<std::pair<size_t, int>> pe, po;
  for (const auto &p: ce)
    pe.emplace_back(p.second, p.first);
  for (const auto &p: co)
    po.emplace_back(p.second, p.first);

  std::sort(pe.begin(), pe.end(), std::greater<>());
  std::sort(po.begin(), po.end(), std::greater<>());

  for (size_t i=0; i<pe.size(); ++i)
    fprintf(stderr, "{%d: %zu}%c", pe[i].second, pe[i].first,
            i+1<pe.size()? ' ':'\n');
  for (size_t i=0; i<po.size(); ++i)
    fprintf(stderr, "{%d: %zu}%c", po[i].second, po[i].first,
            i+1<po.size()? ' ':'\n');

  size_t res=n;

  if (pe[0].second != po[0].second) {
    res = std::min(res, n-pe[0].first-po[0].first);
  } else {
    if (pe.size() > 1) {
      res = std::min(res, n-pe[1].first-po[0].first);
    }
    if (po.size() > 1) {
      res = std::min(res, n-pe[0].first-po[1].first);
    }
    if (pe.size() == 1 && po.size() == 1) {
      res = std::min(res, n/2);
    }
  }
  printf("%zu\n", res);
}

Measured memory_bytes: 9208
#include<stdio.h>
#include<stdlib.h>

#define MAX 10000

int C[MAX+1];

void CountingSort(int A[],int B[],int num);

int main(void)
{
  int *A,*B;
  int i,j,num;

  scanf("%d",&num);

  A=calloc(num+1,sizeof(int));
  B=calloc(num+1,sizeof(int));

  CountingSort(A,B,num);

  for(i=1;i<=num;i++)
    {
      printf("%d",B[i]);

      if(i!=num)
	{
	  putchar(' ');
	}
      else
	{
	  putchar('\n');
	}
    }

  free(A);
  free(B);
  
  return 0;

}

void CountingSort(int A[],int B[],int num)
{
  int i,j;
  
  for(i=0;i<MAX;i++)
    {
      C[i]=0;
    }

  for(i=0;i<num;i++)
    {
      scanf("%d",&A[i+1]);
      C[A[i+1]]++;
    }

  for(i=1;i<MAX;i++)
    {
      C[i]=C[i]+C[i-1];
    }

  for(j=1;j<=num;j++)
    {
      B[C[A[j]]]=A[j];
      C[A[j]]--;
    }
}



Measured memory_bytes: 17064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;

ll X;

int main() {
    cin >> X;

    ll i = 0;
    while(true){

        if(i * (i + 1) / 2 >= X) {break;}
        i++;
    }

	cout << i << endl;
}

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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  string s, t;
  cin >> s >> t;

  t.pop_back();
  cout << (s == t ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 3652
# from sys import exit, stderr
# from inspect import currentframe
# def debug(*args):
#     names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
#     print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args), file=stderr)
#     return
INF = 10e10
H, W = [int(n) for n in input().split()]
c = [["" for __ in range(W)] for _ in range(H)]
B = set()
for i in range(H):
    c[i] = list(str(input()))
    for j in range(W):
        if c[i][j] == "B":
            B.add((i,j))


a = 0
b = INF
c = 0
d = INF
for e in B:
    a = max(e[0] + e[1],a)
    b = min(e[0] + e[1],b)
    c = max(e[0] - e[1],c)
    d = min(e[0] - e[1],d)
print(max(a-b, c-d))



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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int N, M; cin >> N >> M;
    vector<int> L[M];
    rep(i,M){
        int ki; cin >> ki;
        rep(j,ki){
            int s; cin >> s;
            //cout << s << endl;
            L[i].push_back(s-1);
        }
    }
    int P[M];
    rep(i,M){
        int p; cin >> p;
        P[i] = p;
    }

    

    int sum = 0;
    for(int i=0; i<pow(2,N); i++){
        bitset<10> B(i);
        int On_num = 0;
        rep(j,M){
            int Lj_sum = 0;
            rep(k,L[j].size()){
                if(B.test(L[j][k])) Lj_sum++;
            }
            if(P[j] == (Lj_sum%2)) On_num++;
        }
        if(On_num == M){
            sum++;
            // cout << B << endl;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int ans=0;
	string S;
	cin>>S;
	if(S=="RRR")ans=3;
	else if(S=="SRR" || S=="RRS")ans=2;
	else if(S=="SSS")ans=0;
	else ans=1;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3620