akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#include<map>
#include<iostream>
#include<cmath>
#include<queue>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;


int main(){
   ll K;
   cin >> K;
   queue<ll> que;
   for(ll i = 1; i < 10; i++){
      que.push(i);
   }
   ll ans;
   for(ll i = 0; i < K; i++){
      ans = que.front();
      que.pop();
      if(ans % 10 != 0) que.push(10*ans + (ans % 10) - 1);
      que.push(10*ans + (ans % 10));
      if(ans % 10 != 9) que.push(10*ans + (ans % 10) + 1);
   }
   std::cout << ans << endl;
}

Measured memory_bytes: 5172
#! python3
# triangle.py

import math

a, b, C = [int(x) for x in input().split(' ')]

S = a * b * math.sin(math.radians(C)) / 2.0
L = a + b + math.sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * math.cos(math.radians(C)))
h = b * math.sin(math.radians(C))

print('%.5f'%S)
print('%.5f'%L)
print('%.5f'%h)



Measured memory_bytes: 5716
import java.util.Scanner;

public class Main {

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

		String N = sc.next();
		
		if(N.equals("ABC")) {
			System.out.println("ARC");
		}else {
			System.out.println("ABC");
		}

	}
}


Measured memory_bytes: 35672
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)

	aCount := 0
	result := 0
	for i := 0; i < len(s); i++ {
		if s[i] == 'A' {
			aCount += 1
		} else if s[i] == 'B' && i+1 < len(s) && s[i+1] == 'C' {
			result += aCount
			i++
		} else {
			aCount = 0
		}
	}

	fmt.Println(result)
}


Measured memory_bytes: 1920
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll A,B;
	while(cin>>A>>B) {
		cout<<max({A+B, A-B, A*B})<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

class Mod{
    static final long MOD = 1000_000_007;
    static final long[] fact = makeFactorialArray(1000000);
    static final long[] factInv = makeInversedArray(fact);

    public static long add(long a, long b){
        long tmp = (a+b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long adds(long... ar){
        long ans=0;
        for(long x:ar) ans = Mod.add(ans, x);
        return ans;
    }
    public static long sub(long a, long b){
        return add(a,-b);
    }
    public static long mult(long a, long b){
        long tmp = (a*b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long mults(long... ar){
        long ans=1;
        for(long x:ar) ans = Mod.mult(ans, x);
        return ans;
    }
    public static long power(long a, long x){ //calculate a^x
        if(x<0)return 0;
        if(x==0)return 1;
        if(x%2==0) {
            long half = power(a,x/2);
            return mult(half,half);
        }
        return (a*power(a,x-1)) % MOD;
    }
    public static long inverse(long a){
        return power(a,MOD-2);
    }
    public static long div(long a, long b){
        return mult(a, inverse(b));
    }
    public static long[] makeFactorialArray(int size){
        long[] array = new long[size];
        array[0]=1;
        for(int i=1;i<size;i++){
            array[i]=mult(array[i-1],i);
        }
        return array;
    }
    public static long[] makeInversedArray(long[] original){
        long[] array = new long[original.length];
        for(int i=0;i<original.length;i++){
            array[i] = inverse(original[i]);
        }
        return array;
    }
    public static long combination(int n, int r){
        if(n<0 || r<0 || n<r) return 0;
        return mult(fact[n], mult(factInv[r],factInv[n-r]));
    }
    public static long gcd(long a, long b){
        if(a<b) return gcd(b,a);
        if(b==0) return a;
        if(a%b==0) return b;
        return gcd(b,a%b);
    }
    public static long lcm(long a, long b){
        return (a/gcd(a,b))*b;
    }

}
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        boolean[] safe = new boolean[N+1];
        Arrays.fill(safe, true);
        for(int m=0; m<M; m++){safe[sc.nextInt()]=false;}
        long[] route = new long[N+1];
        route[0] = 1;
        route[1] = safe[1] ? 1 : 0;
        for(int n=2; n<=N; n++){
            long onestep = safe[n-1] ? route[n-1] : 0;
            long twostep = safe[n-2] ? route[n-2] : 0;
            route[n] = Mod.add(onestep, twostep);
        }
        System.out.println(route[N]);

    }
}

Measured memory_bytes: 59016
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main(){
	int n,x; cin >> n >> x;
	std::vector<int> L(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> L[i];
	}
	int sum = 0;
	int count = 1;
	for (int i = 0; i < n; ++i)
	{
		sum += L[i];
		if(sum <= x) {
			count++;
		}
	}

	cout << count << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int cnt = 0;
		for(int i = 0; i < 2; i++) {
			if(a < b) {
				cnt = cnt + b;
				b = b - 1;
			}
			else {
				cnt = cnt + a;
				a = a - 1;
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 22868
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int A, B; cin >> A >> B;
    for (int value = 1; value <= 10000; ++value)
    {
        if (static_cast<int>(static_cast<double>(value)* 0.08) == A
            && static_cast<int>(static_cast<double>(value)* 0.1) == B)
        {
            cout << value << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 256
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

vector<string> V(3);

signed main(){

    in(V);
    YN(V[0][V[0].size()-1]==V[1][0]&&V[1][V[1].size()-1]==V[2][0]);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;cin>>n>>k;
  int h[n];for(int i=0;i<n;i++)cin>>h[i];
  int dp[n];
  fill(dp,dp+n,2000000000);
  dp[0]=0;
  for(int i=0;i<n-1;i++){
    for(int j=1;j<=k;j++){
      if(i+j<n){
        dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
      }
    }
  }
  cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <unistd.h>
#include <cctype>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <cmath>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 1 << 30
#define LLINF LLONG_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
using ll = long long;
using Pll = pair<ll,ll>;
using Pii = pair<int,int>;
using Pdd = pair<double,double>;
using dcomplex = complex<double>;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll fact(ll a){ll b=1;for(ll i=1;i<=a;i++)b*=i;return b;}
ll power(ll x,ll n){ll a=1;REP(i,n)a*=x;return a;}
double inf() {return std::numeric_limits<double>::infinity();}

ll X, Y;

int main(int argc, char const *argv[]) {
  string S; cin >> S;
  char s0 = '0';
  int T = S.size();
  REP(i,S.size()) {
    if(s0 != S[i]) T = min(T,max(int(i),int(S.size()-i)));
    s0 = S[i];
  }
  cout << T << endl;
}


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N; scanf("%d", &N);
  vector<ll> A(N);
  for (int i = 0; i < N; ++i) {
    scanf("%lld", &A[i]);
  }
  sort(A.begin(), A.end());
  ll n = A[N - 1], r = -1;
  ll d = numeric_limits<ll>::max();
  for (int i = 0; i < N; ++i) {
    if (abs(n - 2 * A[i]) < d) {
      r = A[i];
      d = abs(n - 2 * A[i]);
    }
  }
  printf("%lld %lld\n", n, r);
  return 0;
}


Measured memory_bytes: 1024
import java.io.*
import java.util.*

fun solve(N: Int, h: IntArray){
    // dp[i] = iにたどり着くまでのコストの最小値
    val dp = IntArray(N)
    dp[0] = 0
    dp[1] = Math.abs(h[1] - h[0])
    for(i in 2 until N){
        dp[i] = Math.min(
            dp[i-1] + Math.abs(h[i-1] - h[i]),
            dp[i-2] + Math.abs(h[i-2] - h[i])
        )
    }
    println(dp[N-1])
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val h = IntArray(N)
    for (i in 0 until N) {
        h[i] = sc.next().toInt()
    }
    solve(N, h)
}



Measured memory_bytes: 39252
#include <bits/stdc++.h>
#define bug cout<<"woc"<<endl

using namespace std;
typedef long long ll;

const int MAX_K=1e5+5;
ll a[MAX_K];

int main(void)
{
    ll k;
    cin >>k;
    for(int i=1;i<=k;i++)
        scanf("%lld",&a[i]);
    reverse(a+1,a+1+k);
    ll mmin=2,mmax=2;
    for(int i=1;i<=k&&mmax>=mmin;i++){
        mmax=(mmax/a[i]+1)*a[i]-1;
        if(mmin%a[i])
        mmin=mmin/a[i]*a[i]+a[i];
    }
    if(mmax>=mmin)  cout<<mmin<<" "<<mmax<<endl;
    else    cout<<"-1"<<endl;
}


Measured memory_bytes: 1024
# def makelist(n, m):
# 	return [[0 for i in range(m)] for j in range(n)]

# n = int(input())
# a, b = map(int, input().split())
# 


s = input()
l = len(s)

if l == 1:
	print(int(s))
else:
	ans = 0

	m = int('1'*(l-1), 2)
	for i in range(m+1):
		now = format(i, 'b').zfill(l-1)
		tmp = s[0]
		for k in range(l-1):
			if now[k] == '0':
				tmp += s[k+1]
			else:
				ans += int(tmp)
				tmp = s[k+1]
		ans += int(tmp)
	print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 1010101010;
string f(LL n,int a,int l)
{
    LL cnt=1ll<<(l-1);
    for(int b=0;b<a;b++)
    {
        if(n>cnt)n-=cnt;
        else
        {
            n=cnt-n;
            string ans="";
            for(int j=0;j<l-1;j++)
            {
                ans+=(char)('0'+((n>>j)&1?b:a));
            }
            ans+=((char)('0'+b));
            reverse(ans.begin(),ans.end());
            return ans;
        }
    }
    if(n>((1ll<<(l-1))-1)*9)n-=((1ll<<(l-1))-1)*9;
    else return ((char)('0'+a))+f(n,a,l-1);
    for(int b=a+1;b<10;b++)
    {
        if(n>cnt)n-=cnt;
        else
        {
            n--;
            string ans="";
            for(int j=0;j<l-1;j++)
            {
                ans+=(char)('0'+((n>>j)&1?b:a));
            }
            ans+=((char)('0'+b));
            reverse(ans.begin(),ans.end());
            return ans;
        }
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL n;
    while(cin>>n,n){
        int l=2;
        while(n>((1ll<<(l-1))-1)*81)
        {
            n-=((1ll<<(l-1))-1)*81;
            l++;
        }
        LL cnt=((1ll<<(l-1))-1)*9;
        int a=1;
        while(n>cnt)
        {
            n-=cnt;
            a++;
        }
        cout<<((char)('0'+a))+f(n,a,l-1)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
const ll mod=1000000007;
const ll INF=1e15;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end())
#define pb push_back
#define mp make_pair
#define MODP(A,B) A=(A+B)%mod
typedef pair<ll,ll> P;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};


//Union-Find Tree

ll par[100001];
ll rnk[100001];
ll Size[100001];
ll N;

void shoki(){
    for(ll i=0;i<100001;i++) {par[i]=i; rnk[i]=0; Size[i]=1;}
}

ll sch(ll x){
    if(par[x]==x) return x;
    else return par[x]=sch(par[x]);
}

void con(ll A,ll B){
    A=sch(A);
    B=sch(B);
    if(A==B) return;
    if(rnk[A]>rnk[B]) swap(A,B);
    par[A]=B;
    Size[B]+=Size[A];
    Size[A]=Size[B];
    if(rnk[A]==rnk[B]) rnk[B]++;

    return;
}

ll is_size(ll k){
    return Size[sch(k)];
}

bool same(ll A,ll B){
    return sch(A)==sch(B);
}

vec NOT[100001];



int main(){
    ll M,K; cin>>N>>M>>K;
    shoki();
    rep(i,M){
        ll A,B; cin>>A>>B;
        A--; B--;
        con(A,B);
        NOT[A].pb(B);
        NOT[B].pb(A);
    }
    rep(i,K){
        ll C,D; cin>>C>>D;
        C--; D--;
        NOT[C].pb(D);
        NOT[D].pb(C);
    }

    vec ans;
    rep(i,N){
        ll ret=is_size(i);
        rep(j,NOT[i].size()) if(same(i,NOT[i].at(j))) ret--;
        ans.pb(ret);
    }
    rep(i,N) cout<<ans.at(i)-1<<' ';
    cout<<endl;

}

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

#define int long long int
#define ff first
#define ss second
#define pb push_back


int bexp(int a, int b)
{
	int res = 1;

	while (b)
	{
		if (b & 1) res = (res * a);

		a = (a * a); 
		b >>= 1;
	}
	return res;
}

int gcd(int a, int b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}

#define N 200010
#define MOD 1000000007


int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(10);

	int a, b, c;
	cin >> a >> b >> c;

	if (a + b - c > 0)
	{
		cout << "No\n";
		return 0;
	}
	
	if ((a + b - c) * (a + b - c) > 4 * a * b)
		cout << "Yes\n";
	else
		cout << "No\n";	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class program{
  static void Main(string[] args){
    program p = new program();
    p.Sta();
  }
  void Sta(){
    WriteLine(Run());
  }
  string Run(){
	int n = int.Parse(ReadLine());
    string[] temp=new string[2];
    string[] s = new string[n];
    int[] t = new int[n];
    for(int i=0;i<n;i++){
      temp= ReadLine().Split();
      s[i]=temp[0];
      t[i]=int.Parse(temp[1]);
    }
    string x=ReadLine();
    int phase=0,ans=0;
    for(int i=0;i<n;i++){
      if(phase==0 && s[i]==x)
        phase=1;
      else if(phase>0)
        ans+=t[i];
    }
    return ans.ToString();
  }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


//monoid,結合律が成り立ち,単位元が存在するものに対しての演算をクエリに対してO(logn)で
//1-indexed  n(親)->2n,2n+1(子)  k(子)->k/2(親)
template<typename Monoid>
struct SegmentTree{
    using F = function< Monoid(Monoid, Monoid) >;
    //sz:size->完全二分木なのでszはnよりも大きい最小の2のべき乗数
    int sz;
    vector<Monoid> seg;
 
    const F f;
    const Monoid M1;
    SegmentTree(int n,const F f,const Monoid &M1) : f(f), M1(M1) {

    sz=1;
    while(sz<n) sz<<=1;
    seg.assign(2*sz, M1);
    }
 
    void set(int k, const Monoid &x){
        seg[k+sz] = x;
    }
 
    void build(){
        for(int k=sz-1;k>0;k--){
        seg[k]=f(seg[2*k+0], seg[2*k+1]);
        }
    }
 
    void update(int k,const Monoid &x){
        k+=sz;
        seg[k]=x;
        
    while(k>>=1){
        seg[k]=f(seg[2*k+0],seg[2*k+1]);
        }
    }
    //query聞くときは区間は[a,b)で(a<=x<b)
    Monoid query(int a, int b) {
        Monoid L=M1,R=M1;
        for(a+=sz,b+=sz;a<b;a>>=1,b>>=1){
            if(a&1) L=f(L, seg[a++]);
            if(b&1) R=f(seg[--b], R);
        }
        return f(L,R);
    }   
    Monoid operator[](const int &k) const{
        return seg[k+sz];
    }
};


ll f(ll a,ll b){return (a+b);}


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

    string S,T;cin>>S>>T;
    SegmentTree<ll> S_seg(S.size(),f,0),T_seg(T.size(),f,0);
    rep(i,S.size()){
        if(S[i]=='A') S_seg.set(i,1);
    }
    rep(i,T.size()){
        if(T[i]=='A') T_seg.set(i,1);
    }
    S_seg.build();T_seg.build();

    int q;cin>>q;
    while(q--){
        int a,b,c,d;cin>>a>>b>>c>>d;
        a--,c--;
        int Sa_cnt=S_seg.query(a,b);
        int Sb_cnt=b-a-Sa_cnt;
        int Ta_cnt=T_seg.query(c,d);
        int Tb_cnt=d-c-Ta_cnt;
        int numS=(Sa_cnt+2*Sb_cnt)%3;
        int numT=(Ta_cnt+2*Tb_cnt)%3;
        if(numS==numT)  cout<<"YES"<<endl;
        else            cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 5072
#include<stdio.h>
int main(){
    int a,b,c,cnt=0;
    scanf("%d %d %d",&a,&b,&c);
    for (int i=a;i<=b;++i){
        if(c%i==0)++cnt;
    }
    printf("%d\n",cnt);
    return 0;
}


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

using namespace std;
using lli = int_fast64_t;
using ulli = unsigned long long;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = copy(x);cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

constexpr lli MOD = (lli)1e9 + 7;
constexpr lli LIMIT = 1000000000000000000 * 5;



int main() {
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		if (i % 2 == 0 && a % 2 == 1) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int maxn=100003;
typedef long long ll;
ll g[maxn];
ll fastpow(ll a,ll n){
	a%=mod;
	ll ans=1;
	while(n){
		if(n&1) ans=(ans*a)%mod;
		a=(a*a)%mod;
		n>>=1;
	}
	return ans;
}
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	//gcd=m的个数*m
	//个数: 
	//n(gcd(1))：k^n-sum(n(gcd(1*m)))(1*m<=k)
	//n(gcd(2))：(k/2)^n-sum(n(gcd(2*m)))(2*m<=k) 
	//n(gcd(p))：(k/p)^n-sum(n(gcd(p*m)))(p*m<=k)
	//n(gcd(k))：1
	ll ans=0;
	ll tmp,sum;
	for(int i=k;i>=1;i--){
		tmp=k/i;
		g[i]=fastpow(tmp,n);
		sum=0;
		for(int j=2*i;j<=k;j+=i){
			sum=(sum+g[j])%mod; 
		}
		g[i]=(g[i]-sum+mod)%mod;//这里要再加上mod，防止为负数 
		ans=(ans+(g[i]*i)%mod)%mod;
	} 
	printf("%lld\n",ans);
}

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


int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> C(M, vector<int>(4, 0));
  int id = 0;
  for(auto& c :C){
    c[0] = id;
    cin >> c[1] >> c[2];
    id++;
  }
  sort(
    C.begin(), C.end(),
    [](const vector<int>& a, const vector<int>& b){
      if(a[1] == b[1]) return a[2] < b[2];
      return a[1] < b[1];
  });
  int pref_id = 1;
  int city_id = 1;
  for(auto& c :C){
    if(c[1] != pref_id){
      city_id = 1;
    }
    pref_id = c[1];
    c[3] = city_id;
    city_id++;
  }
  sort(
    C.begin(), C.end(),
    [](const vector<int>& a, const vector<int>& b){
      return a[0] < b[0];
  });
  for(auto& c :C){
    cout << setfill('0') << right << setw(6) << c[1];
    cout << setfill('0') << right << setw(6) << c[3] << endl;
  }
  return 0;
}


Measured memory_bytes: 7040
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	int h, w;

	cin >> h >> w;
	vector<string> a(h);
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}

	vector<string> red(h, string(w, '.'));
	auto blue = red;

	for (int i = 0; i < h; i++) {
		red[i][0] = '#';
		blue[i][w-1] = '#';

		if (i % 2 == 0) {
			fill(red[i].begin() + 1, red[i].end() - 1, '#');
		} else {
			fill(blue[i].begin() + 1, blue[i].end() - 1, '#');
		}

		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') {
				red[i][j] = '#';
				blue[i][j] = '#';
			}
		}
	}

	for (auto s : red) {
		cout << s << endl;
	}
	cout << endl;
	for (auto s : blue) {
		cout << s << endl;
	}

	return 0;
}


Measured memory_bytes: 1536
#include<iostream>
#include<string>
int main() {
    std::string A;
    std::string B;
    int q = 0;
    int w = 0;
    std::string C;
    std::cin >> A >> B >> q >> w >> C;
    if (A == C) {
        std::cout << q - 1<<" " << w << std::endl;
    }
    else {
        std::cout << q << " " << w - 1 << std::endl;
    }
}


Measured memory_bytes: 256
import heapq


X, Y, A, B, C = map(lambda x: int(x), input().split(" "))
Ps = sorted(list(map(lambda x: int(x), input().split(" "))), reverse=True)
Qs = sorted(list(map(lambda x: int(x), input().split(" "))), reverse=True)
Rs = sorted(list(map(lambda x: int(x), input().split(" "))), reverse=True)

results = []
results.extend(Ps[:X])
results.extend(Qs[:Y])
results.sort()

heapq.heapify(results)
for r in Rs:
    a = heapq.heappop(results)
    if a >= r:
        heapq.heappush(results, a)
        break
    else:
        heapq.heappush(results, r)

print(sum(results))


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void ans1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j;
  //ll n; cin>>n;
  ll a,b,c,d,e,f; cin>>a>>b;
  //string a,b,c,d,e,f; cin>>a>>b>>c;
  //ll a,b,c,d,e,f; cin>>a>>b>>c>>d;
  //string s; cin >> s;
  ll result = 0;
  bool judge = true;
  if(a>=b)swap(a,b);
  if(a>=2&&b>=2) cout<<(a-2)*(b-2)<<endl;
  else if(a==1&&b==1) cout<<1<<endl;
  else cout<<b-2<<endl;

  /*
  vector<ll> a(n);
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  
  for(i=0;i<n;i++){

  }
  */

  return 0;
}

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

int main(){
  int N; cin>>N;
  int a[200]; REP(i,N){ cin >>a[i];}
  reverse(a,a+N);
  REP(i,N-1){
    cout << a[i] << " ";
  }
  cout << a[N-1] <<"\n";
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios::sync_with_stdio(false);
	string  s;
	cin >> s;
	int n = s.size();
	int before = 0, after = 0;
	int self = 0;
	for (int i = 0, l = (n - 1); i < l; i++, l--)
	{
		if (s[i] != s[l])
		{
			self = 1;
			break;
		}
	}
		for (int i = 0, l = (n - 1) / 2 - 1; i < l; i++, l--)
		{
			if (s[i] != s[l])
			{	
			before = 1;
			break;
			}
		}
		for (int i = n-1, l = (n +3) / 2-1; i >l; i--, l++)
		{
			if (s[i] != s[l])
			{
				after = 1;
					break;
			}
		}
	
	if (self == 0 && after == 0 && before == 0)
		cout << "Yes";
	else  cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define Maxn 25
int n,V[Maxn],C[Maxn],ans;

int main() {
	cin >> n;
	for(int i = 1; i <= n; i++) 
		cin >> V[i];
	for(int i = 1; i <= n; i++) 
		cin >> C[i];
	for(int i = 1; i <= n; i++) 
		if (V[i] > C[i])
			ans += V[i] - C[i];
	cout << ans << endl;		
	return 0;
}

Measured memory_bytes: 256
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int A, B, C, K; cin >> A >> B >> C >> K;
    if(K % 2 == 1) {
        int sub = -A + B;
        cout << sub << endl;
    }
    else {
        int sub = A - B;
        cout << sub << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i = n;i >= 0;--i)
#define FOR(i,m,n) for(int i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

int main(void)
{
    string s;
    cin >> s;
    int cnt = 0;

    REP(i,s.size()/2){
        if(s[i] != s[s.size() - 1 - i]){
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S;
    cin >>S;
    int N =S.size();
    int ans=0;
    bool one =false;
    
    int i=0;
    while(i<N){
        if(i==N-2 && S.at(i)==S.at(i+1)){
            ans++;
            break;
        }
        if(one &&S.at(i)==S.at(i-1)){
            ans++;
            i+=2;
            one =false;
        }
        else{
            ans++;
            i++;
            one=true;
        }
    }
    cout <<ans<<endl;

}

Measured memory_bytes: 3724
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 500111

int const dim = 500055;

int n, i, sum, k;
char s[maxN];
int data[maxN];

void mult() {
    int i;

    for (i = 1; i <= n; i++)
        data[i] *= 9;

    for (i = 1; i <= dim; i++) {
        data[i + 1] += data[i] / 10;
        data[i] %= 10;
        sum += data[i];
    }
}

void add() {
    sum += 9;
    data[1] += 9;

    for (int pos = 1; data[pos] >= 10; pos++) {
        sum += data[pos] / 10;
        data[pos + 1] += data[pos] / 10;
        sum -= data[pos];
        data[pos] %= 10;
        sum += data[pos];
    }
}

int main()
{
 //   freopen("test.in","r",stdin);

    scanf("%s", s + 1);
    n = strlen(s + 1);

    for (i = 1; i <= n; i++)
        data[n - i + 1] = s[i] - '0';

    mult();
    for (k = 1; true; k++) {
        add();
        if (sum <= 9 * k) {
            printf("%d", k);
            return 0;
        }
    }


    return 0;
}


Measured memory_bytes: 2808
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<utility>//swapでaとbの値を入れ替える
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define r(s) reverse(s.begin(),s.end())
using namespace std;
int main() {
	int a,b,c,x;
	cin >> a>>b>>c>>x;
	int ans = 0;
	rep(i, a+1) {
		rep(j, b+1) {
			rep(l, c+1) {
				if (500*i+100*j+50*l==x)ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
#include <queue>
#include <unordered_map>
#include <stack>
#include <bitset>
#include <cstdlib>
#include <sstream>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
ll pow(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = pow(N, P/2);
        return t*t;
    }
    return N * pow(N, P-1);
}
ll modpow(ll N, ll P,ll k){
    if(P==0) return 1;
    if(P%2==0){
        ll t = modpow(N, P/2,k)%k;
        return t*t%k;
    }
    return N * modpow(N, P-1,k)%k;
}
ll modkai(ll n,ll m,ll k){//n*(n-1)*(n-2)*...(m+1)%k
    if(n == m)return 1;
    return modkai(n-1,m,k)*n%k;
}
ll mod_cnb(ll n,ll m,ll k){//nCm%k,kは十分大きい素数
  int m_=modkai(m,0,k);
  return modkai(n,n-m,k)*modpow(m_,k-2,k)%k;
}
ll gcd(ll n,ll m){
    ll n_ = max(n,m);
    ll m_ = min(n,m);
    if(n_%m_ == 0)return m_;
    return gcd(m_,n_%m_);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}

int main() {
    int n;cin>>n;
    double ans=0;
    rep(i,n){
        double x;
        string s;cin>>x>>s;
        if(s=="JPY")ans+=x;
        else ans+=x*380000.0;
    }
    cout<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 256
# B - Crane and Turtle
import numpy as np
def is_integer(n):
    try:
        float(n)
    except ValueError:
        return False
    else:
        return float(n).is_integer()
X, Y = map(int, input().split())    
mat = np.array([[2,-0.5],[-1,0.5]])
matb = np.array([[X], [Y]])
Ans = np.dot(mat, matb)
if (is_integer(Ans[0]) is True) and (is_integer(Ans[1]) is True):
    if (Ans[0] >= 0) and (Ans[1] >= 0):
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

int main(){
  string s;
  cin >> s;
  for(int i=0;i<s.size()-1;i++){
    if(s.at(i)==s.at(i+1)){
      cout << i+1 << ' ' << i+2 << endl;
      return 0;
    }
  }
  for(int i=0;i<s.size()-2;i++){
    if(s.at(i)==s.at(i+2)){
      cout << i+1 << ' ' << i+3 << endl;
      return 0;
    }
  }
  cout <<-1<<' '<< -1 << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<double,double>;
using node = tuple<int, int, int>;
const int MAX_N = 500000;
const double inf = numeric_limits<double>::max()/3;
const ll mod = 1e9+7;

int main(void){
  string s;
  int tx,ty;
  cin >> s;
  cin >> tx >> ty;
  int i = 0;
  int cnt = 0;
  while(i < (int)s.size() && s[i] != 'T'){
    ++cnt;
    ++i;
  }
  ++i;
  set< int > x;
  set< int > y;
  x.insert(cnt);
  y.insert(0);
  bool now_x = false;
  cnt = 0;
  while(i < (int)s.size()){
    if(s[i] == 'T'){
      set< int > tmp;
      if(now_x){
        for(int n : x){
          tmp.insert(n + cnt);
          tmp.insert(n - cnt);
        }
        x = tmp;
      }else{
        for(int n : y){
          tmp.insert(n + cnt);
          tmp.insert(n - cnt);
        }
        y = tmp;
      }
      cnt = 0;
      now_x = !now_x;
    }else{
      ++cnt;
    }
    ++i;
  }
  set< int > tmp;
  if(now_x){
    for(int n : x){
      tmp.insert(n + cnt);
      tmp.insert(n - cnt);
    }
    x = tmp;
  }else{
    for(int n : y){
      tmp.insert(n + cnt);
          tmp.insert(n - cnt);
    }
    y = tmp;
  }
  if(x.find(tx) != x.end() &&
     y.find(ty) != y.end()){
    puts("Yes");
  }else{
    puts("No");
  }
  return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n,a,b;
  cin >> n >> a >> b;
  vector<int> h(n);
  int l = 0, r = 1;
  rep(i,n) cin >> h[i], r = max(r,(h[i]+b-1)/b);
  while(l+1<r){
    int c = (l+r)/2;
    bool ok = [&](int x){
      int bx = b*x;
      rep(i,n){
        int hi = h[i]-bx;
        if(hi<=0) continue;
        x -= (hi+(a-b)-1)/(a-b);
        if(x<0) return false;
      }
      return true;
    }(c);
    if(ok){
      r = c;
    }else{
      l = c;
    }
  }
  cout << r << endl;
}

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

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

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

int A[50],B[40],C[50];
int dp[409][409];

void init(int dp[409][409]){
    rep(i,409)rep(j,409) dp[i][j]=INF;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N, M1, M2;
    cin>>N>>M1>>M2;
    
    rep(i,N) cin>>A[i]>>B[i]>>C[i];
    init(dp);
    dp[0][0]=0;
    rep(k,N){
        int nxt[409][409];init(nxt);
        rep(i,409)rep(j,409)if(dp[i][j]!=INF){
            chmin(nxt[i][j],dp[i][j]);
            if(i+A[k]<=400&&j+B[k]<=400) chmin(nxt[i+A[k]][j+B[k]],dp[i][j]+C[k]);
        }
        swap(dp,nxt);
    }
    
    int mn=INF;
    for(int i=1;M1*i<=400&&M2*i<=400;i++){
        chmin(mn,dp[M1*i][M2*i]);
    }
    if(mn==INF) mn=-1;
    cout1(mn)
}

Measured memory_bytes: 1536
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

ll min(ll a, ll b) {return a < b ? a : b;}
ll min(int a, ll b) {return a < b ? a : b;}
ll min(ll a, int b) {return a < b ? a : b;}
ll min(int a, int b) {return a < b ? a : b;}

ll max(ll a, ll b) {return a > b ? a : b;}
ll max(int a, ll b) {return a > b ? a : b;}
ll max(ll a, int b) {return a > b ? a : b;}
ll max(int a, int b) {return a > b ? a : b;}

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()
#define int long long
#define NAME ""

long long n;
long long k;
long long a[500000];
long long b[500000];
long long c[500000];

long long check(int l, int r)
{
    if (l == r)
    {
        if (c[l] > 0)
            return 1;
        return 0;
    }
    if (l > r)
        return 0;
    long long ans = 0;
    int m = (l + r) / 2;
    ans += check(l, m) + check(m + 1, r);
    vector<int> x, y;
    for (int i = m; i >= l; i--) x.push_back(c[i] + (x.size() ? x.back() : 0));
    for (int i = m + 1; i <= r; i++) y.push_back(c[i] + (y.size() ? y.back() : 0));
    sort(all(x));
    sort(all(y));
    reverse(all(y));
    int j = 0;
    for (int i = 0; i < x.size(); i++)
    {
        while (j < y.size() && x[i] + y[j] > 0) j++;
        ans += j;
    }
    return ans;
}

long long g(int x)
{
    for (int i = 0; i < n; i++) c[i] = -1 + 2 * (a[i] <= x);
    //cout << x << " " << check(0, n - 1) << endl;
    return check(0, n - 1);
}

signed main()
{
    if (NAME != "")
    {
        freopen(NAME ".in", "r", stdin);
        freopen(NAME ".out", "w", stdout);
    }
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    cin >> n; k = n * (n + 1) / 2;
    for (int i = 0; i < n; cin >> a[i], b[i] = a[i], i++) ;
    sort(b, b + n);
    int l = -1, r = n;
    while (l + 1 < r)
    {
        int mid = (l + r) / 2;
        if (g(b[mid]) * 2 <= k)
        {
            l = mid;
        }
        else
        {
            r = mid;
        }
    }
    cout << b[r];
}


Measured memory_bytes: 10576
#include <bits/stdc++.h>
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define FOR(I, A, B) for (ll I = (A); I <= (B); I++)
#define fo(i,n) for(ll i=0;i<n;i++)
#define sz(a) ll((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl
#define scan(char_array) scanf("%[^\n]s",&char_array)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
struct point
{
    ll a,b,c;
};
ll visited[55][2600];
ll dp[51][2600];
ll tiime[55][55];
ll cost[55][55];
ll own[55][2];

vector<ll> adj[55];
int main(){
    IOS
  fo(i,51){
    fo(j,3000){
      dp[i][j]=100000000000000000;


    }
  }

  auto compare = [](point a, point b)
                {
                    return a.a>b.a;
                };

    std::priority_queue<point, std::vector<point>, decltype(compare)> pq(compare);

  ll n,m,s;
  cin>>n>>m>>s;
  ll aa,bb,cc,dd;
  fo(i,m){
    cin>>aa>>bb>>cc>>dd;
    adj[aa].pb(bb);
    adj[bb].pb(aa);
    cost[aa][bb]=cc;
    cost[bb][aa]=cc;
    tiime[aa][bb]=dd;
    tiime[bb][aa]=dd;

  }
  fo(i,n){
        cin>>aa>>bb;
        own[i+1][0]=aa;
        own[i+1][1]=bb;
  }
  
  
  s=min((ll)2500,s);
  dp[1][s]=0;
  point tmp;
  tmp.a=0;
  tmp.b=1;
  tmp.c=s;
  pq.push(tmp);

  while(!pq.empty()){
        auto tt=pq.top();
        pq.pop();
        //dbg3(tt.a,tt.b,tt.c);
        if(visited[tt.b][tt.c]) continue;
        visited[tt.b][tt.c]=1;
        ll node=tt.b;

        for(auto kk:adj[node]){
            //dbg3(kk,tt.c,cost[node][kk]);
            if(!(tt.c-cost[node][kk]<0)){ 
                if(!visited[kk][tt.c-cost[node][kk]]){
                    if(dp[kk][tt.c-cost[node][kk]]>dp[node][tt.c]+tiime[node][kk]){
                        dp[kk][tt.c-cost[node][kk]]=dp[node][tt.c]+tiime[node][kk]; 
                        tmp.a= dp[node][tt.c]+tiime[node][kk];
                        tmp.b=kk;
                        tmp.c=tt.c-cost[node][kk];
                        pq.push(tmp);
                    }
                }
            }
        }

        ll extra_cost=own[node][0];
        ll extra_tiime=own[node][1];
        ll neew=min(tt.c+extra_cost,(ll)2500);
        if(!visited[node][neew]&&dp[node][neew]>dp[node][tt.c]+extra_tiime){
            dp[node][neew]=dp[node][tt.c]+extra_tiime;
            tmp.a= dp[node][tt.c]+extra_tiime;
            tmp.b=node;
            tmp.c=neew;
            pq.push(tmp);

        }




  }
  FOR(i,2,n){
        ll miin=1000000000000000;
        FOR(j,0,2500){
            miin=min(miin,dp[i][j]);
        }
        cout<<miin<<endl;

  }



}

Measured memory_bytes: 8152