akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
       
using namespace std;
       
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
 
// #define MAX 100010
 
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES
 
long long int fact[3000];
 
void pre()
{
    fact[0]=1;
    fact[1]=1;
    for(int i=2;i<2005;i++)
    {
        fact[i]= (fact[i-1]*i)%MOD;
    }
}
 
long long int poww(long long int a,long long int b)
{
    if(b==0)
        return 1;
    long long int x = poww(a,b/2)%MOD;
    if(b%2==0)
    {
        return (x*x)%MOD;
    }
    else
    {
        return (((x*x)%MOD)*a)%MOD;
    }
}

int countt[1000000];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        // freopen("input.txt","r",stdin);
        // freopen("output.txt","w",stdout);
    #endif
    long long int x;
    cin>>x;
    if(x<=6)
        cout<<1;
    else if(x<=11)
        cout<<2;
    else
    {
        long long int ans = 0;
        ans = (x)/11;
        ans*=2;
        if(x%11!=0)
        {
            if(x%11<7)
                ans++;
            else 
                ans+=2;
        }
        cout<<ans;
    }
    cout<<endl;
    return 0;
}

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

int main()
{
    int N,W;
    cin >> N >> W;
    
    ll dp[110][110000];
    dp[0][0]=0;
    
    ll w[110],v[110];
    
    for(int i=1;i<=N;++i)
    {
        cin >> w[i] >> v[i];    
    }
    
    for(int i=1;i<=N;++i)
    {
        for(int j=0;j<=W;++j)
        {
            dp[i][j]=dp[i-1][j];
            if(j-w[i]>=0)
            dp[i][j]=max(dp[i][j],dp[i-1][j-w[i]]+v[i]);
        }
    }
    cout << dp[N][W] << endl;
    
    return 0;
}

Measured memory_bytes: 81956
#include<cstdio>
using namespace std;
int main(){
	double a[8],matrix[4],ans[2];
	while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7]) != EOF){
		matrix[0] = a[2]-a[0];
		matrix[1] = a[4]-a[0];
		matrix[2] = a[3]-a[1];
		matrix[3] = a[5]-a[1];
		ans[0] = a[6]-a[0];
		ans[1] = a[7]-a[1];
		double t = matrix[0]*matrix[3]-matrix[1]*matrix[2];
		double x = matrix[3]*ans[0]/t-matrix[1]*ans[1]/t;
		double y = matrix[0]*ans[1]/t-matrix[2]*ans[0]/t;
		if(x+y<1 && x>0 && y>0){printf("YES\n");}
		else{printf("NO\n");}
	}
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

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; }

ll g(ll n) {return n * (n+1) / 2;}


int main()
{   
    ll n;
    cin >> n;
    string ans = "";
    while(n) {
        --n;
        ans = char(n%26+'a') + ans;
        n /= 26;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
#[allow(unused_imports)]
use std::cmp::max;
#[allow(unused_imports)]
use std::fmt;
#[allow(unused_imports)]
use std::fmt::Debug;
#[allow(unused_imports)]
use std::io;
#[allow(unused_imports)]
use std::str::FromStr;

fn main() {
    let input = get_vec_input();
    let a: f64 = input[0];
    let b: f64 = input[1];
    let d: f64 = input[2] * std::f64::consts::PI / 180.0;
    let s = a * b * d.sin() / 2.0;
    let c = (a * a + b * b - 2.0 * a * b * d.cos()).sqrt();
    println!("{} {} {}", s, a + b + c, 2.0 * s / a);
}

#[allow(dead_code)]
fn sum_digit2(value: String) -> u32 {
    return value.chars().fold(0u32, |a, b| a + b.to_digit(10).unwrap());
}

#[allow(dead_code)]
fn sum_digit(value: i64) -> i64 {
    if value < 10 {
        return value;
    }
    return sum_digit(value / 10) + value % 10;
}

#[allow(dead_code)]
fn update_max<T>(left: &mut T, right: T)
where
    T: std::cmp::Ord + std::clone::Clone,
{
    if *left < right {
        *left = right.clone();
    }
}

#[allow(dead_code)]
fn update_min<T>(left: &mut T, right: T)
where
    T: std::cmp::Ord + std::clone::Clone,
{
    if *left > right {
        *left = right.clone();
    }
}

#[allow(dead_code)]
fn get_vec_input<T>() -> Vec<T>
where
    T: FromStr,
    T::Err: Debug,
{
    let mut input = String::new();
    io::stdin()
        .read_line(&mut input)
        .expect("Failed to read line");
    let vec: Vec<T> = input
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    vec
}

#[allow(dead_code)]
fn get_tuple_input() -> (u64, f32) {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    let mut iter = s.trim().split_whitespace();
    let c: u64 = iter.next().unwrap().parse().unwrap();
    let n: f32 = iter.next().unwrap().parse().unwrap();
    (c, n)
}

#[allow(dead_code)]
fn get_string_input() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    s.trim().to_string()
}



Measured memory_bytes: 5184
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

map<ll, ll> prime_factor(ll n){
    map<ll,ll> com;
    for(ll i = 2LL; i*i<=n; ++i){
        while(n%i==0LL){
            com[i]++;
            n /= i;
        }
    }
    if(n != 1LL)com[n]++;
    return com;
}

// int main(){
// 	int N; cin>>N;
// 	map<ll, ll> all_fact;
// 	vector<int> A(N);
// 	rep(i,N)cin>>A[i];
// 	rep(i,N){
// 		map<ll, ll> t = prime_factor(A[i]);
// 		for(auto x: t){
// 			all_fact[x.first] += x.second;
// 		}
// 		if(A[i] == 1){cout<<0<<endl; return 0;}
// 	}

// 	int ans = 0;
// 	sort(all(A), greater<int>());
// 	rep(i,N){
// 		map<ll, ll> t = prime_factor(A[i]);
// 		for(auto x: t){
// 			all_fact[x.first] -= x.second;
// 		}
// 		bool e_ans = true;
// 		for(auto x: t){
// 			if(all_fact.count(x.first) != 0)e_ans = false;
// 		}
// 		if(e_ans)++ans;
// 	}
// 	cout<<ans<<endl;
// 	return 0;
// }

int main(){
	int N; cin>>N;
	int ans = 0;
	vector<int> A(N);
	map<int,int> check;

	rep(i,N){
		cin>>A[i];
		check[A[i]]++;
	}
	rep(i,N){
		vector<int> fact;
		bool e_ans = true;
		for(int k = 1; k*k <= A[i];++k){
			if(A[i]%k == 0){
				fact.push_back(k);
				fact.push_back(A[i]/k);
			}
		}
		for(auto x: fact){
			if(x == A[i]){
				if(check[x] > 1)e_ans = false;
				continue;
			}
			if(check.count(x) == 1){e_ans = false;}
		}
		if(e_ans)ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 13552
#include <bits/stdc++.h>
    using namespace std;
    
    int main(){
        long  a , b ;
        string str;
        cin >> a >> str >> b;
        if(str == "+"){
            cout << a + b << endl;
        }else{
            cout << a - b << endl;
        }
        return 0;
    }

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main() {
    int a,b;
    scanf("%d %d",&a,&b);
    int ans = 0;
    int num = 1;
    while(num < b) {
        ans++;
        num += a - 1;    
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 998244353;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

constexpr ll V = 1000000;

ll mod_pow (ll x, ll y) {
    ll ret = 1;
    while (y) {
        if (y&1) ret = ret * x % MOD;
        x = x * x % MOD;
        y /= 2;
    }
    return ret;
}

ll N;
ll A[200000];
ll C[V+1];
ll w[V+1];

void init() {
    for (ll i = 1; i <= V; i++) {
        w[i] = (mod_pow(i,MOD-2) + w[i] + MOD) % MOD;
        for (ll j = i*2; j <= V; j += i) {
            w[j] = (w[j] - w[i] + MOD) % MOD;
        }
    }
}

int main() {
    init();
    cin >> N;
    rep(i,N) cin >> A[i];
    rep(i,N) C[A[i]]++;
    ll ans = 0;
    for (ll i = 1; i <= V; i++) {
        ll add = 0;
        ll sum1 = 0, sum2 = 0;
        for (ll j = i; j <= V; j += i) {
            sum1 = (sum1 + C[j]*j) % MOD;
            sum2 = (sum2 + C[j]*(j*j%MOD)) % MOD;
        }
        add = (sum1*sum1-sum2+MOD)%MOD;
        add = add * mod_pow(2, MOD-2) % MOD;

        ans = (ans + add*w[i]) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 17408
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	ll N, K;
	cin >> N >> K;
	vector <ll> h(N, 0);
	for (int ii = 0; ii < N; ++ii){
		cin >> h[ii];
	}

	vector <ll> dp(N, 100100100100);
	dp[0] = 0;
	for (int ii = 1; ii < N; ++ii){
		for (int jj = 1; jj <= K; ++jj){
			if (ii - jj >= 0){
				dp[ii] = min(dp[ii], dp[ii-jj] + abs(h[ii]-h[ii-jj]));
			}
		}
	}
	
	cout << dp[N-1] << endl;

	return 0;
}


Measured memory_bytes: 1792
#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++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

void YesNo(bool x) {
    if (x) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main() {
    int A, B; cin >> A >> B;
    cout << A * B << endl;
}


Measured memory_bytes: 3596
#include<stdio.h>

int binary(int a[], int n, int key){
        int left=0, right=n, mid;
        while(left<right){
                mid=(left+right)/2;
                if(a[mid]==key){
                        return 1;
                }else if(key<a[mid]){
                        right=mid;
                }else{
                        left=mid+1;
                }
        }
        return -1;
}

int main(){
        int i, key, n, q, count=0;
        scanf("%d", &n);
        int s[n];
        for(i=0; i<n; i++){
                scanf("%d", &s[i]);
        }
        scanf("%d", &q);

        for(i=0; i<q; i++){
                scanf("%d", &key);
                if(binary(s, n, key)==1)
                        count++;
        }

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

        return 0;
}



Measured memory_bytes: 2108
import java.util.Scanner;

public class Main {

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

		int N = Integer.parseInt(sc.next());

		int len = Integer.toString(N).length();
		int oddNum = 0;
		int idx = 0;

		for (idx = len; idx > 0; idx--) {
			switch (idx) {
			case 5:
				if (idx == len) {
					oddNum += (N - 9999);
				} else {
					oddNum += 90000;
				}
				break;
			case 3:
				if (idx == len) {
					oddNum += (N - 99);
				} else {
					oddNum += 900;
				}
				break;
			case 1:
				if (idx == len) {
					oddNum += N;
				} else {
					oddNum += 9;
				}
				break;
			default:
				break;
			}
		}

		System.out.println(oddNum);

	}

}


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

queue<int> q;
int num[233333], sum[233333];
string ls;
int main()
{
    int n, k, ans = 0;
    cin >> n >> k;
    cin >> ls;
    bool flag = 0;
    int s, t, kk = k;
    for (int i = 1; i <= n; i++)
    {
        num[i] = ls[i-1] - '0';
    }
    ans = 0;
    //if (num[1])
    //{
        s = 0;
        q.push(s);
    //}
    for (int i = 1; i <= n; i++)
    {
        if (num[i] == 0)
        {
            if (!kk)
            {
                kk++;
                ans = max(ans, i-q.front()-1);
                q.pop();
            }
            while (num[i] == 0 && i <= n)
            {
                i++;
            }
            q.push(i-1);
            i--;
            kk--;
        }
    }
    if (!q.empty())
        ans = max(ans, n-q.front());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int k = sc.nextInt();

        char target = s.charAt(k - 1);

        for (int i = 0; i < n; i++) {
            if (s.charAt(i) == target) {
                System.out.print(target);
            } else {
                System.out.print("*");
            }
        }

    }
}


Measured memory_bytes: 23252
a,b = map(int,input().split())
if a == 1:
  if b == 1:
    print('Draw')
  else:
    print('Alice')
elif b == 1:
  print('Bob')
else:
  if a == b:
    print('Draw')
  elif a > b:
    print('Alice')
  else:
    print('Bob')

Measured memory_bytes: 3060
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<ctime>
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
		return F?n:-n;
	}
}
const int M=1000000007;
int f[2222][2222];
int main()
{
	int n=io::F(),m=io::F(),k=io::F();
	for(register int i=1;i<k;++i)
		if(k-i<=n&&i<=m)f[k-i][i]=1;
	for(int i=k;i<n+m;i+=k-1)
		for(int j=1;j<=n;++j)
			if(i-j>0&&i-j<=m&&f[j][i-j])
			{
				register int F=f[j][i-j];
				for(register int l=0;l<k;++l)
					if(j+l<=n&&i-j+k-1-l>0&&i-j+k-1-l<=m)(f[j+l][i-j+k-1-l]+=F)%=M;
			}
	int ans=0;
	for(register int i=n;i>=0;i-=k-1)
		for(register int j=m;j>=0;j-=k-1)
			(ans+=f[i][j])%=M;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 18560
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <string>
#include <utility>

#define repd(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue();
void inputArray(int*,int);
void inputVector(vector<int>*,int);
template <typename T>
void output(T,int);
int gcd(int a,int b);

int main(){
	//source
	int n;
	cin >> n;
	int a[n];
	rep(i,n){
		int temp;
		cin >> temp;
		a[i]=temp-(i+1);
	}
	sort(a,a+n);
	ll ans=0;
	rep(i,n){
		ans+=abs(a[i]-a[n/2]);
	}
	cout << ans << endl;
	return 0;
}

int inputValue(){
	int a;
	cin >> a;
	return a;
}

void inputArray(int *p,int a){
	rep(i,a){
		cin >> p[i];
	}
}

void inputVector(vector<int> *p,int a){
	rep(i,a){
		int input;
		cin >> input;
		p -> push_back(input);
	}
}

template<typename T>
void output(T a,int precision){
	if(precision > 0){
		cout << setprecision(precision) << a << "\n";
	}else{
		cout << a << "\n";
	}
}

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


Measured memory_bytes: 1024
import java.util.Map.Entry;
import java.util.*;
import java.math.*;
import org.w3c.dom.css.Counter;
  
public class Main{
    public static void main(final String[] args){
       
        final Scanner sc = new Scanner(System.in);
        int X =sc.nextInt();
        int N =sc.nextInt();
        int keepNum =999;
        int ans =999;
        HashSet hoge =new HashSet<Integer>();
        if(N==0){
            System.out.println(X);
            return;
        }
        for(int i=0;i<N;i++){
                hoge.add(sc.nextInt());
            }
        for(int i=0;i <=X;i++){
            if(hoge.contains(X-i)==false){
                System.out.println(X-i);
                return;
            
            }else if(hoge.contains(X+i)==false){
                System.out.println(X+i);
                return;
            }
        }
    }
}
        //全部亀
/*         int kameFoot = headSum * 4;
        if(kameFoot >= footSum){
            if((kameFoot-footSum)%2==0&&(kameFoot-footSum)/2 <=headSum){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else{
            System.out.println("No");
        }

       } */
    
        /*  int N =sc.nextInt();
        int K =sc.nextInt();
        Map<Integer,Integer> numMap = new HashMap<>();
        Map<Integer,Integer> newMap = new HashMap<>();
        Map<Integer,Integer> hogeMap = new HashMap<>();
        if(N>41){

        }
        for(int i =1;i<=N;i++){
            numMap.put(i, sc.nextInt());
            newMap.put(i,0);
            hogeMap.put(i,0);
        }
        for(int i= 0;i<K;i++){
            //newMap =  numMap;

            for(int i2= 1; i2<=N;i2++){

                    for(int i4 =0 ;i4 <=numMap.get(i2)&&i4+i2<=N;i4++){
                        newMap.replace(i2+i4, newMap.get(i2+i4)+1);
                        if(i4<i2&&i4 != 0){
                            newMap.replace(i2-i4, newMap.get(i2-i4)+1);
                        }
                    }
   /*                  for(int i4 =1 ;i4<i2&&i4<=numMap.get(i2);i4++){
                        newMap.replace(i2-i4, newMap.get(i2-i4)+1);
                    } */


Measured memory_bytes: 35812
package main

import "fmt"

func main() {
  var N int
  cake := 4
  dounut := 7
  inc := 0
  fmt.Scan(&N)

  for c := 0; c * cake <= N; c++ {
    for d := 0; d * dounut <= N; d++{
      total := cake * c + dounut * d
      if N == total {
        inc ++
      }
    }
  }

  if inc > 0 {
    fmt.Println("Yes")
  } else {
    fmt.Println("No")
  }
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a >= b && a >= c){
    cout << b + c << endl;
  }else if(b >= a && b >= c){
     cout << a + c << endl;
  }else{
  cout << a + b << endl;
  }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
  
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <cassert>
#include <numeric>
#include <math.h>
#include <bitset>
#include <random>
#include <regex>

using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,f,n) for(int i=f;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
constexpr int dy[] = {0,1,0,-1,1,-1,-1,1};
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class A, class B> inline A updiv(const A a,const B b){ return (a + b - 1) / b; }
template <class A, class B> inline A gcd(const A a,const B b){ return b ? gcd(b,a % b) : a; }
template <class A, class B> inline A lcm(const A a,const B b){ return a / gcd(a,b) * b; }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;

#define double long double

signed main(void){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int a, b, h, m;
    cin >> a >> b >> h >> m;

    double x = h * 30;
    double y = m * 6;
    x += m / 60.0 * 30;

    double ad = min(x, y);
    double bd = max(x, y);

    double d = min(bd - ad, 360 - bd + ad);

    d = d * (3.1415926535897932384 / 180);

    cout << Fixed << sqrtl(a * a + b * b - 2 * a * b * cos(d)) << '\n';

    return 0;
}

Measured memory_bytes: 3860
#include<bits/stdc++.h>
using namespace std;
#define nl '\n'
int main()
{
    int n,sum=0,k,a;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
       cin>>a;
       if(a>=k)
         sum++;
    }
    cout<<sum;
    nl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=2e5+10;
int n,k,c,cnt,pos,sta[N],top;
bool vis[N]; char s[N];

int main() {
	scanf("%d %d %d %s",&n,&k,&c,s+1);
	for(int i=1;i<=n;i++) {
		if(pos>=i||s[i]=='x') continue;
		vis[i]=1; pos=i+c; if(++cnt>k) return 0;
	}
	pos=n+1;
	for(int i=n; i;i--) {
		if(pos<=i||s[i]=='x') continue;
		pos=i-c; if(vis[i]) sta[++top]=i;
	}
	while(top) printf("%d\n",sta[top--]);
	return 0;
}


Measured memory_bytes: 2560
# coding: utf-8
# Your code here!
import copy
n, m = map(int, input().split())
H = list(map(int, input().split()))
A = []
for i in range(m):
    A.append(list(map(int,input().split())))
# print(A)
T = copy.copy(H)
# print(T)

for i in range(m):
    if H[A[i][0]-1] > H[A[i][1]-1]:
        T[A[i][1]-1] = 0
    elif H[A[i][0]-1] < H[A[i][1]-1]:
        T[A[i][0]-1] = 0
    else:
        T[A[i][0]-1] = 0
        T[A[i][1]-1] = 0
    
cnt = 0    
for i in range(n):
    if T[i] != 0:
        cnt = cnt + 1
print(cnt)



Measured memory_bytes: 32220
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    int a, b;
    cin >> a >> b;
    int ans = (a + b) % 24;
    cout << ans << endl;
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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


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

int main() {
    int n; cin >> n;
    int Max = 1;
    int Min = 1<<30;
    rep(i,n) {
        int num; cin >> num;
        Max = max(Max, num);
        Min = min(Min, num);
    }
    cout << abs(Max-Min) << endl;
    return 0;
}

Measured memory_bytes: 256
import re
import sys
from itertools import product

import numpy as np

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def solve():
    A, B, C = il()
    return "Yes" if A < C < B or B < C < A else "No"


if __name__ == "__main__":
    print(solve())


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

#define pb push_back
#define F first
#define S second
#define int long long
#define lint long long
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define SET(x, val) memset(x, val, sizeof(x))
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 2e5 + 5, MOD1 = 1e9 + 7, MOD2 = 998244353;
const lint INF = 1e18;

int n, l[N], a[N], pw[N], lt[N], rt[N];
signed main()
{
    cin >> n;
    pw[0]=1;
    for(int i = 0; i <= n; i++)
    {
        if(i>=1) pw[i]=min(INF, pw[i-1]*2);
        cin >> l[i];
    }
    lt[n]=l[n], rt[n]=l[n];
    int ans=0;
    for(int i = n-1; i >= 0; i--)
    {
        lt[i] = lt[i+1]/2 + (lt[i+1]%2!=0) + l[i];
        rt[i] = min(rt[i+1] + l[i], pw[i]);
        //cout << lt[i] << " " << rt[i] << endl;
        if(lt[i]>rt[i])
        {
            cout << -1;
            return 0;
        }
    }
    int mx = 1;
    for(int i = 0; i <= n; i++)
    {
        if(mx<lt[i])
        {
            cout << -1;
            return 0;
        }
        int cmax = min(mx, rt[i]);
        ans += cmax;
        mx = (cmax - l[i])*2;
    }
    cout << ans;
}

Measured memory_bytes: 6780
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;

int main()
{
	string S;
	cin >> S;
	S[3] = '8';
	cout << S << endl;

	return 0;
}


Measured memory_bytes: 256
import qualified Data.Vector as V (Vector, fromList, length, (!))
import Control.Applicative


binarySearch :: V.Vector Int -> Int -> Bool
binarySearch vec a = loop (0, V.length vec - 1)
  where
    loop (start, end)
      | v == a       = True
      | start >= end = False
      | v > a        = loop (start, n - 1)
      | v < a        = loop (n + 1, end)
      where
        (n, v) = (div (start + end) 2, vec V.! n)

main :: IO ()
main = do
  _ <- getLine
  s <- map read . words <$> getLine
  _ <- getLine
  t <- map read . words <$> getLine
  print $ length $ filter (binarySearch $ V.fromList s) t



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

int main(){

  int N;
  cin>>N;
  vector<int> d(N);
  for(int i=0;i<N;i++){
  cin>>d.at(i);
  }
  
  sort(d.begin(),d.end());
  
  int count=1;
  
  for(int i=0;i<N-1;i++){

    if(d.at(i+1)>d.at(i))count++;

  }
  
  cout<<count;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<complex>
#include<string.h>
using namespace std;
typedef long long int llint;
int main(){
	char s[1000];
	cin >> s;
	sort(s, s + strlen(s));
	for (int i = 1; i < strlen(s); i++){
		if (s[i] == s[i - 1]){
			cout << "no" << endl;
			return 0;
		}
	}
	cout << "yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn main() {
    input!{
      n: usize,
      k: u64,
      aa: [u64; n],
    }
    if n == 1 {
        if k == aa[0] {
            println!("{}", "POSSIBLE");
        } else {
            println!("{}", "IMPOSSIBLE");
        }
        return;
    }

    let mut aa = aa;
    aa.sort();
    if aa[n-1] < k {
        println!("{}", "IMPOSSIBLE");
        return;
    }

    let mut g = aa[0];
    for i in 0..n {
        g = gcd(g, aa[i]);
    }
    if k%g == 0 {
        println!("{}", "POSSIBLE");
    } else {
        println!("{}", "IMPOSSIBLE");
    }
}


Measured memory_bytes: 4352
N, Q = list(map(int, input().split()))
s = input()
spells =  [input().split() for i in range(Q)]

def sim(pos, s, spells, N):
    for sp in spells:
        if s[pos] == sp[0]:
            pos += -1 if sp[1] == "L" else 1
            if pos < 0:
                return "LDead"
            if pos >= N:
                return "RDead"
    return "Alive"

#LD探し
Lpos = -1
Rpos = N
while Lpos+1<Rpos:
    pos = (Lpos+Rpos)//2
    if sim(pos, s, spells, N) == "LDead":
        Lpos = pos
    else:
        Rpos = pos
LDpos = Lpos ###LDeadの中で一番境界に近いもの

#RD探し
Lpos = -1
Rpos = N
while Lpos+1<Rpos:
    pos = (Lpos+Rpos)//2
    if sim(pos, s, spells, N) == "RDead":
        Rpos = pos
    else:
        Lpos = pos
RDpos = Rpos ###RDeadの中で一番境界に近いもの

print(max(0,RDpos-LDpos-1))

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

namespace ConsoleApp18
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] iti = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
            long[] ni = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
            long[] san = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
            long nsuu = int.Parse(Console.ReadLine());
            long teki = 0;
            for(long i =0; i< nsuu; i++)
            {
                teki = int.Parse(Console.ReadLine());
                for (long n =0; n< 3; n++)
                {
                    if (iti[n] == teki)
                    {
                        iti[n] = -1;
                    } else if (ni[n] == teki)
                    {
                        ni[n] = -1;
                    } else if (san[n] == teki)
                    {
                        san[n] = -1;
                    }

                }
            }
            //結果出る誤リオス
            bool hantei = false;
            if (iti[0]== -1 &&iti[1] == -1 && iti[2] == -1)
            {
                hantei = true;
            }else if (ni[0] == -1 && ni[1] == -1 && ni[2] == -1)
            {
                hantei = true;
            }
            else if(san[0] == -1 && san[1] == -1 && san[2] == -1)
            {
                hantei = true;
            }
            else if (iti[0] == -1 && ni[1] == -1 && san[2] == -1)
            {
                hantei = true;
            }else if (iti[2] == -1 && ni[1] == -1 && san[0] == -1)
            {
                hantei = true;
            }
            for (long n = 0; n < 3; n++)
            {
                if(iti[n] == -1 && ni[n] == -1 && san[n] == -1)
                {
                    hantei = true;
                }
            }
            if (hantei)
            {
                Console.WriteLine("Yes");
            } else
            {
                Console.WriteLine("No");
            }
          }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

int main() {
	int k;
	ll mn = 2, mx = 2,xmn,xmx;
	cin >> k;
	vector<ll> v(k);
	rep(i, k) {
		cin >> v[k-i-1];
	}
	rep(i, k) {
		xmn = (mn + v[i] - 1) / v[i] * v[i];
		xmx = (mx / v[i])*v[i];
		if (xmx < xmn) {
			cout << -1 << endl;
			return 0;
		}
		mx = xmx+v[i] - 1;
		mn = xmn;
	}
	cout << mn << " " << mx << endl;

}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define N 101000
using namespace std;
int a[N],b[N],n,m=0,f[N],ans=0,q[N],w[N];
map<int,int> c;
int gf(int x){return f[x]==0?x:f[x]=gf(f[x]);}
void pedg(int x,int y)
{
	int jy=c[x];
	if(jy==0) c[x]=++m;
	jy=c[y];
	if(jy==0) c[y]=++m;
	x=c[x],y=c[y];
	x=gf(x);y=gf(y);
	if(x!=y) f[x]=y;
}
int main()
{
	scanf("%d",&n);
	fo(i,1,n) scanf("%d",&a[i]),a[n+1]^=a[i],q[i]=a[i];
	fo(i,1,n) scanf("%d",&b[i]),b[n+1]^=b[i],w[i]=b[i];
	q[n+1]=a[n+1];w[n+1]=b[n+1];
	sort(q+1,q+n+2);sort(w+1,w+n+2);
	int jy=0;
	fo(i,1,n) if(a[i]!=b[i]&&b[i]==a[n+1]) jy=1;
	fo(i,1,n+1) if(q[i]!=w[i]) return printf("-1\n"),0;
	fo(i,1,n+1) if(a[i]!=b[i]) pedg(a[i],b[i]),ans+=(i<=n);
	fo(i,1,m) ans+=(f[i]==0);
	printf("%d\n",ans-jy);
}

Measured memory_bytes: 8448
N = int(input())
H = list(map(int, input().split()))
count = 0
while any(x > 0 for x in H):
    if H[-1] == 0:
        while H[-1] == 0:
            del H[-1]
    if H[0] == 0:
        while H[0] ==0:
            del H[0]
    for i in range(len(H)):
        if H[i] == 0:
            if H[i + 1] != 0:
                count +=1
        else:
            H[i] -= 1
    count += 1
print(count)

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

int main()
{
	 int a, b, t;
	 cin >> t >> a >> b;
	 
	 if (a*t<b)
	 {
	 	cout << a*t << endl;
	 	return 0;
	 }
	 else if (a*t==b)
	 {
	 	cout << b << endl;
	 	return 0;
	 }
	 else if (a*t>b)
	 {
	 	cout << b << endl;
	 	return 0;
	 }
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

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

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

int main(void){
    int N,M; cin >> N >> M;
    VVI v(M);
    REP(i,M){
        int k; cin >> k;
        REP(j,k){
            int s; cin >> s;
            s--;
            v[i].push_back(s);
        }
    }
    VI p(M); REP(i,M) cin >> p[i];

    int ans = 0;
    REP(i,1<<N){
        bool flag = true;
        REP(j,M){
            int tmp = 0;
            for(int k : v[j]){
                if(i>>k & 1) tmp++;
            }
            if(tmp%2 != p[j]){
                flag = false;
                break;
            }
        }
        if(flag) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
/*--------------------template--------------------*/

int main() {
    cin >> s;
    int K;
    cin >> K;
    ll size = s.size();
    
    set<string> ans;
    vector<string> prevs;
    REP(i, size) {
        string c = string { s[i] };
        vector<string> curs;
        curs.push_back(c);
        for (string prev : prevs) {
            if ((int)prev.size() < K)
                curs.push_back(prev + c);
        }
        for (string cur : curs) {
            ans.insert(cur);
        }
        prevs = curs;
    }
    auto iter = ans.begin();
    REP(i, K-1) iter++;
    cout << *iter << endl;
    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>


using namespace std;

int main(){
  int a,b;
  cin>>a>>b;
  if(a%2==0||b%2==0){
    cout<<"Even"<<endl;
  }
  else{
    cout<<"Odd"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
A, B = map(int, input().split())

lb_a = int(-(-A // 0.08))
ub_a = int(-(-(A + 1) // 0.08) - 1)

lb_b = int(-(-B // 0.1))
ub_b = int(-(-(B + 1) // 0.1) - 1)

if ub_b < lb_a or ub_a < lb_b:
    print(-1)
else:
    print(max(lb_a, lb_b))


Measured memory_bytes: 61732
#include <iostream>
#include<vector>
using namespace std;
vector<long long>dsu;

long long PathCompression(long long a) {
	int node;
	if (dsu[a] < 0) {
		return a;
	}
	else {
		return dsu[a] = PathCompression(dsu[a]);

	}

}
void Union(long long a, long long b) {
	long long x = dsu[a]; long long y = dsu[b];  long long index1 = a; long long index2 = b; bool detectcycle = false;
	index1 = PathCompression(a);
	index2 = PathCompression(b);
	x = dsu[index1];
	y = dsu[index2];

	if (index1 == index2) {
		detectcycle = true;
	}
	if (!detectcycle) {
		if (x <= y) {
			dsu[index1] = dsu[index1] + dsu[index2];
			dsu[index2] = index1;



		}
		else {
			dsu[index2] = dsu[index2] + dsu[index1];
			dsu[index1] = index2;

		}
	}


}

int main() {
	int n; cin >> n; int  m; cin >> m; int count = 0;
	dsu.resize(n, -1);
	for (int i = 0; i < m; i++) {
		int x, y, z;
		cin >> x >> y >> z;
		Union((x-1),( y-1));
	}

	for (int i = 0; i < n; i++) {
		if (dsu[i] < 0) {
			count++;
		}
	}
	cout << count;

}

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

using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ll = long long int;
using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>;
using vd = vector<double>; using vvd = vector<vd>; using vvvd = vector<vvd>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using cdouble = complex<double>;

const double eps = 1e-7;
#define Loop(i, n) for(int i = 0; i < int(n); i++)
#define Loopll(i, n) for(ll i = 0; i < ll(n); i++)
#define Loop1(i, n) for(int i = 1; i <= int(n); i++)
#define Loopll1(i, n) for(ll i = 1; i <= ll(n); i++)
#define Loopr(i, n) for(int i = int(n) - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = ll(n) - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = int(n); i >= 1; i--)
#define Looprll1(i, n) for(ll i = ll(n); i >= 1; i--)
#define Foreach(buf, container) for(auto buf : container)
#define Loopdiag(i, j, h, w, sum) for(int i = ((sum) >= (h) ? (h) - 1 : (sum)), j = (sum) - i; i >= 0 && j < (w); i--, j++)
#define Loopdiagr(i, j, h, w, sum) for(int j = ((sum) >= (w) ? (w) - 1 : (sum)), i = (sum) - j; j >= 0 && i < (h); j--, i++)
#define Loopdiagsym(i, j, h, w, gap) for (int i = ((gap) >= 0 ? (gap) : 0), j = i - (gap); i < (h) && j < (w); i++, j++)
#define Loopdiagsymr(i, j, h, w, gap) for (int i = ((gap) > (h) - (w) - 1 ? (h) - 1 : (w) - 1 + (gap)), j = i - (gap); i >= 0 && j >= 0; i--, j--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(ex_i, vector.size()) { cout << vector[ex_i] << " "; } cout << endl;
#define printmx(matrix) Loop(ex_i, matrix.size()) { Loop(ex_j, matrix[ex_i].size()) { cout << matrix[ex_i][ex_j] << " "; } cout << endl; }
#define quickio() ios::sync_with_stdio(false); cin.tie(0);
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
#define Comp(type_t) bool operator<(const type_t &another) const
#define fst first
#define snd second
#define INF INFINITY
bool feq(double x, double y) { return abs(x - y) <= eps; }
bool inrange(ll x, ll t) { return x >= 0 && x < t; }
bool inrange(vll xs, ll t) { Foreach(x, xs) if (!(x >= 0 && x < t)) return false; return true; }
int ceillog2(ll x) { int ret = 0;	x--; while (x > 0) { ret++; x >>= 1; } return ret; }
ll rndf(double x) { return (ll)(x + (x >= 0 ? 0.5 : -0.5)); }
ll floorsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (m * m <= x ? 0 : -1); }
ll ceilsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (x <= m * m ? 0 : 1); }
ll rnddiv(ll a, ll b) { return (a / b + (a % b * 2 >= b ? 1 : 0)); }
ll ceildiv(ll a, ll b) { return (a / b + (a % b == 0 ? 0 : 1)); }
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }

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

int main() {
	int n; cin >> n;
	vector<P> a(n);
	Loop(i, n) {
		cin >> a[i].fst;
		a[i].snd = i;
	}
	sort(a.begin(), a.end(), greater<P>());
	Loop(i, n) {
		if (i == a[0].snd) {
			cout << a[1].fst << endl;
		}
		else {
			cout << a[0].fst << endl;
		}
	}
}

Measured memory_bytes: 3200
/*input
3 2
1 2
2 3
*/
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
using ll = long long;
using ld = long double;
using pii = pair<ld,ld>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll INF64=4e18;
const int INF=1e6+1;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll sub(ll a,ll b){
    ll x=a-b;
    while(x<0) x+=MOD;
    while(x>MOD) x-=MOD;
    return x;
}
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=(res*a);
        if(res>1e10) return 1e11;
        a=(a*a);
        b>>=1;
    }
    return res;
}
const ll maxn=605;
const ll maxlg=__lg(maxn)+2;
vector<int> v[maxn],v2[maxn];
int n;
ld deg[maxn];
ld E[maxn],P[maxn];
bool adj[maxn][maxn];
int main(){
    int m;
    cin>>n>>m;
    REP(i,n) REP(j,n) adj[i][j]=false;
    FILL(deg,0);
    REP(i,m){
        int a,b;
        cin>>a>>b;
        --a;
        --b;
        adj[a][b]=true;
        deg[a]++;
    } 
    FILL(E,0);
    FILL(P,0);
    P[0]=1;
    REP(i,n){
        for(int j=i+1;j<n;j++){
            if(!adj[i][j]) continue;
            P[j]+=P[i]/deg[i];
        }
    }
    for(int i=n-1;i>=0;i--){
        REP(j,i){
            if(!adj[j][i]) continue;
            E[j]+=(E[i]+1)/deg[j];
        }

    }
    ld ans=E[0];
    REP(i,n){
        if(deg[i]==1) continue;
        for(int j=i+1;j<n;j++){
          if(adj[i][j]){
            ld val=E[0];
            val-=P[i]*E[i];
            ld cur=E[i];
            cur--;
            cur*=deg[i];
            cur-=E[j];
            cur/=(deg[i]-1);
            cur++;
            val+=cur*P[i];
            ans=min(ans,val);
          }
        }
    }
    cout<<setprecision(20)<<ans;
}


Measured memory_bytes: 640
# 入力
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

n, ma, mb = li()
a,b,c = list(), list(), list()
for _ in range(n):
    ai,bi,ci = li()
    a.append(ai)
    b.append(bi)
    c.append(ci)
    
INF = 10**5
dp = [[[INF for _ in range(10*n+1)] for _ in range(10*n+1)] for _ in range(n+1)]
dp[0][0][0] = 0

for dr in range(n):
    for wa in range(10*n+1):
        for wb in range(10*n+1):
            dp[dr+1][wa][wb] = min(dp[dr][wa][wb], dp[dr][wa-a[dr]][wb-b[dr]] + c[dr])
            
ans = INF
k = 1
while k*ma <= 10*n and k*mb <= 10*n:
    ans = min(ans, dp[n][k*ma][k*mb])
    k += 1
    
if ans == INF:
    print(-1)
else:
    print(ans)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
#define PB		push_back

int n, m, l, r[8], a, b, c, d[200][200];

int main(int argc, char **argv) {
	cin >> n >> m >> l;
	REP(i, l) {
		cin >> r[i];
		--r[i];
	}
	sort(r, r + l);
	REP(i, n) REP(j, n) d[i][j] = INF;
	REP(i, m) {
		cin >> a >> b >> c;
		--a; --b;
		d[a][b] = d[b][a] = c;
	}
	REP(k, n) REP(i, n) REP(j, n) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	int res = INF;
	do {
		int t = 0;
		REP(i, l - 1) t += d[r[i]][r[i + 1]];
		res = min(res, t);
	} while (next_permutation(r, r + l));
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 384