akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using PP = pair<long, long>;
const int INF = 1e9;
template <class T> T Next() { T buf; cin >> buf; return buf; }

long input() {
  long ret = 0;
  char c;
  while (c = getchar(), isdigit(c)) {
    ret *= 10;
    ret += c - '0';
  }
  return ret;
}

const long INFLL = 1e18;
int main() {
  int a = input();
  int b = input();
  int c = input();
  int z = input();
  
  vector<long> s, t, u;
  s.reserve(a + 1);
  t.reserve(b + 1);
  u.reserve(c + 1);
  for (int i = 0; i < a; ++i) s.push_back(input());
  for (int i = 0; i < b; ++i) t.push_back(input());
  for (int i = 0; i < c; ++i) u.push_back(input());
  
  sort(s.rbegin(), s.rend());
  sort(t.rbegin(), t.rend());
  sort(u.rbegin(), u.rend());
  s.push_back(-INFLL);
  t.push_back(-INFLL);
  u.push_back(-INFLL);
  
  using Pair = pair<long, int>;
  
  unordered_set<int> st;
  st.reserve(z + 1);
  
  vector<Pair> mem;
  mem.reserve(2 * z + 1);
  priority_queue<Pair> Q(std::less<Pair>(), move(mem));
  Q.push(make_pair(s[0] + t[0] + u[0], 0));
  
  int cnt = 0;
  while (cnt < z) {
    auto q = Q.top(); Q.pop();
    long sc = q.first;
    int pos = q.second;
    if (st.count(pos)) continue;
    st.insert(pos);
    
    int i =  pos        & 0x3ff;
    int j = (pos >> 10) & 0x3ff;
    int k = (pos >> 20) & 0x3ff;
    
    printf("%lld\n", sc);
    Q.push(make_pair(s[i + 1] + t[j] + u[k], pos +  1       ));
    Q.push(make_pair(s[i] + t[j + 1] + u[k], pos + (1 << 10)));
    Q.push(make_pair(s[i] + t[j] + u[k + 1], pos + (1 << 20)));
    ++cnt;
  }
}


Measured memory_bytes: 512
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let (_n, m) = i.read2::<usize, usize>();
    let mut py = Vec::new();
    for c in 0..m {
        py.push((i.read2::<usize, usize>(), c));
    }
    py.sort();

    let mut p_last = None;
    let mut idx = 0;

    let mut rs = Vec::new();

    for ((p, _y), c) in py {
        if Some(p) != p_last {
            idx = 0;
            p_last = Some(p);
        }
        idx += 1;
        rs.push((c, p, idx));
    }
    rs.sort();

    for r in rs {
        writeln!(o, "{:>06}{:>06}", r.1, r.2).unwrap();
    }
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


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

using namespace std;

struct Node {
    int value;
    Node* next;
    Node* prev;
};

Node* init_list() {
    Node* node = new Node;
    node->next = node;
    node->prev = node;
    return node;
}

void insert_node(Node* head, int value) {
    Node* new_node = new Node;
    new_node->value = value;

    Node* node = head->next;
    head->next = new_node;
    new_node->prev = head;
    new_node->next = node;
    node->prev = new_node;
}

void delete_node(Node* head, int value) {
    Node* node = head->next;
    while (node != head) {
        if (node->value == value)
            break;
        node = node->next;
    }

    if (node != head) {
        node->prev->next = node->next;
        node->next->prev = node->prev;
    }
}

void delete_first(Node* head) {
    Node* node = head->next;
    if (node != head) {
        head->next = node->next;
        node->next->prev = head;
        delete node;
    }
}

void delete_last(Node* head) {
    Node* node = head->prev;
    if (node != head) {
        node->prev->next = node->next;
        node->next->prev = node->prev;
        delete node;
    }
}

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

    int n;
    cin >> n;

    Node* head = init_list();

    for (int i = 0; i < n; ++i) {
        string cmd;
        cin >> cmd;

        int value;
        if (cmd == "insert") {
            cin >> value;
            insert_node(head, value);
        } else if (cmd == "delete") {
            cin >> value;
            delete_node(head, value);
        } else if (cmd == "deleteFirst") {
            delete_first(head);
        } else {
            delete_last(head);
        }
    }

    Node* node = head->next;
    if (node != head)
        cout << node->value;
    node = node->next;
    while (node != head) {
        cout << ' ' << node->value;
        node = node->next;
    }
    cout << '\n';

    Node* tmp;
    node = head->next;
    while (node != head) {
        tmp = node;
        node = node->next;
        delete tmp;
    }
    delete head;
}



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

typedef long long ll;

#define rep(i, n) for (int i = 0; i < (ll)n; ++i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;

int N;

void dfs(string s, char mx)
{
    if (s.length() == N)
        cout << s << endl;
    else
    {
        for (char c = 'a'; c <= mx; c++)
        {
            if (c == mx)
                dfs(s + c, mx + 1);
            else
                dfs(s + c, mx);
        }
    }
}

void solve(void)
{
    cin >> N;
    dfs("", 'a');
}

int main(void)
{
    solve();
}


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

int main(){
    int n;
    cin  >> n;
    int sum = 0;
    int num = n;
    int amari;
    while(num){
        amari = num % 10;
        sum += amari;
        num = num /10;
    }
    if(n%sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn input_vec() -> Vec<u64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

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

fn main() {
    let n: u64 = input();
    let mut a_vec = input_vec();
    let mut gcds: Vec<u64> = Vec::new();
    let mut gcds_reverse: Vec<u64> = Vec::new();
    let mut buf = a_vec[0];
    for a in &a_vec {
        buf = gcd(buf, *a);
        gcds.push(buf);
    }

    buf = a_vec[a_vec.len() - 1];
    a_vec.reverse();
    for a in &a_vec {
        buf = gcd(buf, *a);
        gcds_reverse.push(buf);
    }
    gcds_reverse.reverse();
    a_vec.reverse();

    // println!("{:?}", gcds);
    // println!("{:?}", gcds_reverse);
    let mut max = 0;
    for i in 0..a_vec.len() {
        let num: u64;
        if i == 0 {
            num = gcds_reverse[i + 1];
        } else if i == a_vec.len() - 1 {
            num = gcds[i - 1];
        } else {
            num = gcd(gcds[i - 1], gcds_reverse[i + 1]);
        }
        if num > max {
            max = num;
        }
    }
    println!("{}", max);
}


Measured memory_bytes: 10492
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 998244353
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	vector<ll> a(3); cin >> a[0] >> a[1] >> a[2];
	sort(a.begin(), a.end());
	if (a[0] % 2 == 0 || a[1] % 2 == 0 || a[2] % 2 == 0)
		cout << 0 << endl;
	else
		cout << a[0] * a[1]  << endl;
}

Measured memory_bytes: 3592
// JAI SHREE RAM
#pragma GCC optimize("O3")
typedef long long int ll;
typedef unsigned long long int ull;
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define sz(a) int((a).size())
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define loop for(int i=0;i<n;i++)
#define max3(a,b,c) max(a,max(b,c))
#define max4(a,b,c,d) max3(a,max(b,c),d)
#define max5(a,b,c,d,e) max4(a,max(b,c),d,e)
#define min3(a,b,c) min(a,min(b,c))
#define min4(a,b,c,d) min3(a,min(b,c),d)
#define min5(a,b,c,d,e) min4(a,min(b,c),d,e)
#define sec second
#define fir first
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repe(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
// #define all(a) (a).begin(),(a).end()
#define vec vector<int>
#define M_PI           3.14159265358979323846  /* pi */
#define pb push_back
#define pii pair<int,int>
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
std::vector<string> que(100005);
std::vector<char> k(100005);
ll n;
void dp(ll a, ll b, ll c, ll i)
{
	if (a < 0 || b < 0 || c < 0 )
	{
		return ;
	}
	if (i == n)
	{
		cout << "Yes\n";
		for (int i = 0; i < n; i++)
			cout << k[i] << endl;
		//cout<<"yo";
		exit(0);
	}
	else
	{
		if (que[i] == "AB")
		{
			k[i] = 'A';
			dp(a + 1, b - 1, c, i + 1);
			k[i] = 'B';
			dp(a - 1, b + 1, c, i + 1);
		}
		else if (que[i] == "AC")
		{
			k[i] = 'A';
			dp(a + 1, b , c - 1, i + 1);
			k[i] = 'C';
			dp(a - 1, b , c + 1, i + 1);
		}
		else
		{
			k[i] = 'B';
			dp(a , b + 1, c - 1, i + 1);
			k[i] = 'C';
			dp(a , b - 1, c + 1, i + 1);
		}

	}
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fast
	cin >> n;
	ll a, b, c;
	cin >> a >> b >> c;
	for (ll i = 0; i < n; i++)
	{
		cin >> que[i];
	}

	dp(a, b, c, 0 );
	cout << "No\n";



	return 0;
}


Measured memory_bytes: 14260
#include <stdio.h>

int digit_sum(int x){
  int s=0;
  while(x>0){
      s+=x%10;
      x=x/10;
  }
  return s;
}

int main(void){
  int i,n,m,min=100,s=0;
  scanf("%d",&n);
  m=n/2;
  for(i=1;i<=m;i++){
    s=digit_sum(i)+digit_sum(n-i);
    if(s<min){
      min=s;
    }
    s=0;
  }
  printf("%d\n",min);
  return 0;
}


Measured memory_bytes: 128
while 1:
    m, f, r = map(int, input().split())
    if m + f + r == -3: break
    s = m + f
    if m == -1 or f == -1: print("F")
    elif s < 30: print("F")
    elif s >= 80: print("A")
    elif s >= 65: print("B")
    elif s >= 50: print("C")
    elif s >= 30 and r >= 50: print("C")
    else: print("D")



Measured memory_bytes: 5592
#include <stdio.h>

int main(void)
{
	/*
	長方形の座標は左下を(0,0)、右上を(w,h)
	円の中心座標は(x,y)、半径をr
	*/
	int w, h, x, y, r;

	//scanf関数でデータを取得
	scanf("%d %d %d %d %d",&w, &h, &x, &y, &r);

	/*
	x + rは右の最大の座標、x - rは左の最大の座標
	y + rは上の最大の座標、y - rは下の最大の座標
	*/
	if((x + r <= w && x - r >= 0) && (y + r <= h && y - r >= 0)){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}

	return 0;
}


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

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


int main(){
	ll n ; cin >> n ; cout << 48-n << endl ;
}




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

ll A[20];
ll f(int s, int e, int l, int r) {
	if (s > e) return 0;
	ll ret = 1ll << 62;
	for (int i = s; i <= e; ++i) ret = min(ret, f(s, i - 1, l, l + r) + f(i + 1, e, l + r, r) + (l + r) * A[i]);
	return ret;
}

int main() {
 	ios_base::sync_with_stdio(0), cin.tie(0);
 	int N; cin >> N;
 	for (int i = 1; i <= N; ++i) cin >> A[i];
	cout << f(2, N - 1, 1, 1) + A[1] + A[N];
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
typedef long long ll;

int main(void)
{
    char ans[5];

    int n;
    scanf("%d", &n);

    if (n % 10 == 3)
        puts("bon");
    else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8)
        puts("pon");
    else
        puts("hon");

    return 0;
}

Measured memory_bytes: 1644
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  long int a, b;
  cin >> a;
  b = a * 2;
  cout << b * pi << "\n";
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e6 + 10;

int modpow(int x, int n, int m) {
	x %= m;
	int res = 1;
	while(n > 0) {
		if(n & 1)
			res = res * x % m;
		x = x * x % m;
		n >>= 1;
	}
	return res;
}

int fact[N], invfact[N];

void pre() {
	fact[0] = 1;
	for(int i = 1; i < N; i++) {
		fact[i] = fact[i - 1] * i % mod;
	}
	invfact[N - 1] = modpow(fact[N - 1], mod - 2, mod);
	for(int i = N - 2; i >= 0; i--) {
		invfact[i] = invfact[i + 1] * (i + 1) % mod;
	}
}

int ncr(int x, int y) {
	if(y < 0 || y > x)
		return 0;
	int res = fact[x] * invfact[y] % mod * invfact[x - y] % mod;
	return res;
}

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	pre();
	int k;
	string s;
	cin >> k >> s;
	int n = s.length();
	int ans = modpow(26, n + k, mod);
	for(int i = 0; i < n; i++) {
		ans = (ans - ncr(n + k, i) * modpow(25, n + k - i, mod) % mod + mod) % mod;
	}
	cout << ans;

	return 0;
}

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

int main(){
  int N,K;
  cin >> N >> K;
  string S;
  cin >> S;
  char x = S.at(K-1);
  if(x=='A'){
    S.at(K-1) = 'a';
  }else if(x=='B'){
    S.at(K-1) = 'b';
  }else{
    S.at(K-1) = 'c';
  }
  cout << S << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e18;
const double PI=3.1415926535897932;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod

ll A,B,C,D;
map<ll,ll> memo, memo2;
ll Count=0;
ll Solve(ll N){
    //Count++;
    //cout<<N<<' '<<Count<<endl;
    //if(Count>=100) return INF;
    if(N==0) return 0;
    if(N==1) return D;
    if(memo.count(N)) {
        //cout<<"Solved"<<N<<endl;
        return memo[N];
    }
    //cout<<"arrived"<<N<<endl;
    ll ret=INF;
    if((INF/N)>D) ret=N*D;
    ll a1=N/2, a2=a1; if(N%2) a2++;
    ll memory=0;
    //cout<<N<<' '<<2<<' '<<a1<<' '<<a2<<endl;
    if(Solve(a1)<=INF-A-D*(N-a1*2)) if(ret>Solve(a1)+A+D*(N-a1*2)) {ret=Solve(a1)+A+D*(N-a1*2); memory=a1;}
    if(Solve(a2)<=INF-A-D*(a2*2-N)) if(ret>Solve(a2)+A+D*(a2*2-N)) {ret=Solve(a2)+A+D*(a2*2-N); memory=a2;}
    a1=N/3; a2=a1; if(N%3) a2++;
    if(Solve(a1)<=INF-B-D*(N-a1*3)) if(ret>Solve(a1)+B+D*(N-a1*3)) {ret=Solve(a1)+B+D*(N-a1*3); memory=a1;}
    if(Solve(a2)<=INF-B-D*(a2*3-N)) if(ret>Solve(a2)+B+D*(a2*3-N)) {ret=Solve(a2)+B+D*(a2*3-N); memory=a2;}
    a1=N/5; a2=a1; if(N%5) a2++;
    if(Solve(a1)<=INF-C-D*(N-a1*5)) if(ret>Solve(a1)+C+D*(N-a1*5)) {ret=Solve(a1)+C+D*(N-a1*5); memory=a1;}
    if(Solve(a2)<=INF-C-D*(a2*5-N)) if(ret>Solve(a2)+C+D*(a2*5-N)) {ret=Solve(a2)+C+D*(a2*5-N); memory=a2;}
    memo[N]=ret;
    memo2[N]=memory;
    return ret;
}

void COUT(ll N){
    if(N==0 || N==1) return;
    COUT(memo2[N]);
    cout<<memo2[N]<<"->"<<N<<':'<<memo[N]<<endl;
    return;
}
int main(){
    //cout<<158766448204*987654321<<endl;
    ll T; cin>>T;
    vec ans;
    rep(i,T) {
        ll N;
        cin>>N>>A>>B>>C>>D;
        memo.clear(); memo2.clear();
        ans.pb(Solve(N));
        //COUT(N);
    }
    rep(i,T) cout<<ans[i]<<endl;
    
}

Measured memory_bytes: 5200
#include<iostream>
#include<cstring>

using namespace std;
char word[1000];
char sent[100000];
int main() {
	//freopen("in","r",stdin);
	while(cin>>word+1) {
		if(word[1]=='-'&&strlen(word+1)==1) break;
		int n; cin>>n; int sum = 0, here = 0;
		for(int i=0;i<n;i++) {
			cin>>here; sum += here;
		}
		sum %= strlen(word+1);
		sum++;
		for(int i=sum;i<=strlen(word+1);i++) cout<<word[i];
		for(int i=1;i<sum;i++) cout<<word[i];
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3072
n = int(input())
s = input()

changes = 0

for i in range(n):
    if s[i] == "#":
        changes += 1

min_changes = changes

for i in range(n):
    if s[n - 1 - i] == ".":
        changes += 1
    else:
        changes -= 1
    
    if changes < min_changes:
        min_changes = changes

print(min_changes)

Measured memory_bytes: 3500
#include <iostream>
#include <vector>

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=a,i##_len=(b);i<i##_len;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;
typedef long long ll;
typedef unsigned long long ull;

int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
    ull n, a, b;
    cin >> n >> a >> b;

    if (a == 0 && b == 0) {
        cout << 0 << endl;
        return 0;
    }

    ull div = n / (a + b);
    ull r = n % (a + b);

    ull rest = min(r, a);


    cout << (div * a) + rest << endl;

    return 0;
}


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

int main(){
	int N;
	int v;

	cin >> N;

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

	if(N==1)
		cout << A[0] << endl;
	else{
		for(int k=0;k<N-1;k++){
			cout << A[k] << " "; 
		}
		cout << A[N-1] << endl; 

		for(int i=1;i<N;i++){
			int j=i-1;
			v = A[i];
			while(j >= 0 && A[j] > v){
				A[j+1] = A[j];
				j--;
			}
			A[j+1] = v;
			for(int k=0;k<N-1;k++){
				cout << A[k] << " "; 
			}
			cout << A[N-1] << endl;
		}
	}

	return 0;
}

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

using namespace std;

int main() {
    int N, L;
    cin >> N >> L;

    int ideal = 0;
    for (int i = 1; i <= N; i++)
    {
        ideal += L + i - 1;
    }
    
    int ans = 100000000;
    for (int i = 1; i <= N; i++)
    {
        ans = min(ans, abs(L + i - 1));
        //cout << ans << endl;
    }

    if (abs(ideal - ans) < abs(ideal + ans))
    {
        cout << ideal - ans << endl;
    }
    else
    {
        cout << ideal + ans << endl;
    }
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;
Node treeMinimum(Node x){
  while(x->left!=NIL) x=x->left;
  return x;
}
Node treeSearch(Node u, int k){
  if(u==NIL || u->key==k) return u;
  else if(u->key > k) return treeSearch(u->left,k);
  else if(u->key < k) return treeSearch(u->right,k);
  //else return u;

}
Node treeSuccessor(Node x){
  if(x->right!=NIL) return treeMinimum(x->right);
  Node y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left==NIL || z->right==NIL) y=z;
  else y=treeSuccessor(z);

  if(y->left!=NIL) x=y->left;
  else x=y->right;

  if(x!=NIL) x->parent=y->parent;

  if(y->parent==NIL) root=x;
  else if(y==y->parent->left) y->parent->left=x;
  else y->parent->right=x;

  if(y!=z) z->key=y->key;

}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NIL) root=z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;		      
}

void inorder(Node u){
    if (u->left != NIL) inorder(u->left);
    printf(" %d",u->key);
    if (u->right!=NIL) inorder(u->right);
}
void preorder(Node u){
  printf(" %d",u->key);
  if(u->left!=NIL) preorder(u->left);
  if(u->right!=NIL) preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
  return 0;
}

Measured memory_bytes: 19364
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
 
public class Main {
 
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = null;
         
        try {
            while((line = br.readLine()) != null) {
                line = line.trim();
                String[] values = line.split("\\s");
                if(values.length != 6) System.exit(-1);
                double[] value = new double[6];
                int i = 0;
                for(String s : values) {
                    value[i] = Integer.parseInt(s);
                    if(value[i] < -1000 || value[i] > 1000) System.exit(-1);
                    i++;
                }
                 
                double a = value[0];
                double b = value[1];
                double c = value[2];
                double d = value[3];
                double e = value[4];
                double f = value[5];
                 
                double x = (c*e - f*b) / (a*e - b*d);
                double y = (c*d - f*a) / (b*d - a*e);
                 
                BigDecimal bdX = new BigDecimal(x);
                BigDecimal bdY = new BigDecimal(y);
                bdX = bdX.setScale(3, BigDecimal.ROUND_HALF_UP);
                bdY = bdY.setScale(3, BigDecimal.ROUND_HALF_UP);
 
                System.out.println(bdX + " " + bdY);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
         
    }
 
}

Measured memory_bytes: 24388
N,M = map(int,input().split())
sc = [list(map(int,input().split())) for i in range(M)]

dic = {}
dic2= {}
try:
    for i in range(N):
        dic[i] = 0
    for i in sc:
        if (i[0]-1 not in dic2.keys()):
            dic2[i[0]-1] = i[1]
        elif (i[0]-1 in dic2.keys()) and (i[1] != dic2[i[0]-1]):
            raise ValueError("error!")
            
    if (N > 1) and (0 in dic2) and (dic2[0] == 0):
        raise ValueError("error!")

    dic.update(dic2)
    
    s = ''
    for v in dic.values():
        s += str(v)
    if (N > 1) and (s[0] == '0'):
        s = s.replace('0','1',1)
    print(s)

except ValueError as e:
    print(-1)

Measured memory_bytes: 9240
#include<iostream>
#include<cstdio>
#include<cmath>

using namespace std;

int main(){
    int a,b,C;
    double S, L, h,d;
    cin >> a>>b>>C;
    
    d=(acos(-1.0)*C)/180.0;
    S=a*b*sin(d)/2.0;
    L=a+b+sqrt(a*a +b*b -2*a*b*cos(d));
    h=b*sin(d);
    
    printf("%lf\n%lf\n%lf\n", S,L,h);
    
    return 0;
}


Measured memory_bytes: 3388
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

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

  int n;
  cin >> n;

  int ans = 1;
  while (ans * 2 <= n) {
    ans *= 2;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int x[10],y[10];

double dist(int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}


int main(){
    int n;
    cin >> n;
    double sum=0.0;
    for(int i=1; i<=n; i++) cin >> x[i] >> y[i];


    //n!通りの処理
    //1,2,3,4...となるベクトルを作る
    vector<int> v(n);
    rep(i,n) v[i] = i+1;

    do{
        rep(i,n-1) sum += dist(v[i],v[i+1]);
    }while(next_permutation(all(v)));

    //パターンはn!あるのでn!を計算
    int fact = 1;
    for(int i=2; i<=n; i++) fact *= i;

    cout << fixed << setprecision(10) <<  sum / fact << endl;

}

Measured memory_bytes: 4196
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int a = sc.nextInt();
        String s = sc.next();
        if (a >= 3200) {
            System.out.println(s);
            return;
        }
        System.out.println("red");
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 20564
#include <bits/stdc++.h>
using namespace std;
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; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;

int main() {
    int N; cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    
    int q; cin >> q;
    vector<int> B(q);
    vector<bool> C(q, false);
    for (int i = 0; i < q; i++) cin >> B[i];

    for (int tmp = 0; tmp < (1 << N); tmp++) {
        bitset<20> b(tmp);
        int sum = 0;

        for (int i = 0; i < N; i++) {
            if (b.test(i)) {
                sum += A[i];
            }
        }

        for (int i = 0; i < q; i++) {
            if (sum == B[i]) {
                C[i] = true;
            }
        }
    }

    for (int i = 0; i < q; i++) {
        if (C[i]) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

int a[100010], dp[100010];
signed main(void)
{
  int n;
  cin >> n;
  REP(i, n) cin >> a[i];
  fill(dp, dp+n, INF);
  REP(i, n) *lower_bound(dp, dp+n, a[i]) = a[i];
  cout << lower_bound(dp, dp+n, INF) - dp << endl;
  return 0;
}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }

string s, t;
void solve() {
    cin >> s >> t;
    cout << t + s << endn;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
int sa[114514],sb[114511],ta[114514],tb[114514];
signed main(){
    string s,t;cin>>s>>t;
    sa[0]=0,sb[0]=0,ta[0]=0,tb[0]=0;
    rep(i,0,s.size()){
        if(s[i]=='A'){
          sa[i+1]=sa[i]+1;
            sb[i+1]=sb[i];
        }
        if(s[i]=='B'){
            sa[i+1]=sa[i];
            sb[i+1]=sb[i]+1;
        }
    }
    rep(i,0,t.size()){
        if(t[i]=='A'){
            ta[i+1]=ta[i]+1;
            tb[i+1]=tb[i];
        }
        if(t[i]=='B'){
            ta[i+1]=ta[i];
            tb[i+1]=tb[i]+1;
        }
    }
    int q;cin>>q;
    rep(i,0,q){
       int a,b,c,d;cin>>a>>b>>c>>d;
        int saa=sa[b]-sa[a-1],sbb=sb[b]-sb[a-1];
        int taa=ta[d]-ta[c-1],tbb=tb[d]-tb[c-1];
        int sum=saa*2+sbb-tbb-taa*2;
        //cout<<saa<<" "<<sbb<<" "<<taa<<" "<<tbb<<" ";
       // cout<<sum<<" ";
        if(sum%3==0)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
 
typedef double db;
typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const ll MOD = 1e9+7;
const double PI  = 3.14159265358;
const double EPS = 1e-8;

#define INT_MX 2147483647
#define INF ((int)1e9)
#define LLINF ((ll)1e18)
#define F first
#define S second
#define MP(x,y) make_pair(x,y)
#define siz(v) ((int)v.size())
#define rs(n) resize(n)
#define ALL(v) v.begin(),v.end()
#define reset(v) memset((v),0,sizeof(v))
#define EB emplace_back
#define PB push_back
#define PF push_front
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,a,b) for(int i=(a);i<(b);i++) 
#define vec vector
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

void solve(){
	ll n, k, cnt, ans = 1;
	
	cin >> n >> k;
	cnt = 1;
	
	while(k*cnt <= n){
		cnt *= k;
		ans++;
	}
	cout << ans << '\n';
	
	
}

int main(){
	int T = 1;
	
	while(T--){
		solve();
	}
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lp3(i,a,b) for(int i=a;i<b;i++)
#define lp2(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	string o,e,ans;
	cin>>o>>e;
	//cout<<o[0]<<e[0];
	lp2(i,o.size()){
		if(o.size()==e.size()){
		ans+=o[i];
		ans+=e[i];
		}
		else{
			if(i!=o.size()-1){
				ans+=o[i];
				ans+=e[i];
			}
			else ans+=o[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main () {
	LL n, k; cin >> n >> k;
	if (n % k == 0) cout << 0;
	else if (n < k) cout << min (n, k - n);
	else cout << k % (n % k);

	return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque
input = sys.stdin.readline


def main():
    h, w = map(int, input().split())
    ch, cw = map(int, input().split())
    dh, dw = map(int, input().split())
    
    ch += 1
    cw += 1
    dh += 1
    dw += 1
    
    
    s = ["#"*(w+4)]
    s.append("#"*(w+4))
    for i in range(h):
        s.append("##" + input()[:-1] + "##")
    s.append("#"*(w+4))
    s.append("#"*(w+4))
    
    
    ans = [[-1]*(w+4) for _ in range(h+4)]
    for i in range(h+4):
        for j in range(w+4):
            if s[i][j] == "#":
                ans[i][j] = -2
    ans[ch][cw] = 0
    
    move = [(-1, 0), (1, 0), (0, -1), (0, 1)]
    not_yet = deque([(ch, cw)])
    one_time = deque([])
    
    while len(not_yet) > 0:
        x, y = not_yet.popleft()
        one_time.append((x, y))
        for (p, q) in move:
            if ans[x+p][y+q] == -1:
                not_yet.append((x+p, y+q))
                ans[x+p][y+q] = ans[x][y]
                
        if len(not_yet) == 0:
            while len(one_time) > 0:
                x2, y2 = one_time.popleft()
                for i in range(x2-2, x2+3):
                    for j in range(y2-2, y2+3):
                        if ans[i][j] == -1:
                            ans[i][j] = ans[x2][y2]+1
                            not_yet.append((i, j))
          
    print(ans[dh][dw])
    
    
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 93616
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
const int INFTY =2147483647;
int main(){
    ll n,g=0,b=0,r=0,x=0;
    string s;
    cin>>n>>s;
    REP(i,n){
        if(s[i]-'R'==0)g++;
        else if(s[i]-'G'==0)b++;
        else r++;
    }
    int i=1;
    while(i*2<n){
        for(int j=0;j+i*2<n;j++){
            if(s[j]-s[j+i]!=0&&s[j+i]-s[j+i*2]!=0&&s[j]-s[j+i*2]!=0)x++;
        }
        i++;
    }
    cout<<g*b*r-x<<endl;
}

Measured memory_bytes: 3592
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
from decimal import *
 
# N以上でMを割り切ることができる最小の数nを求める　→ 答え M//n
N, M = MAP()

def make_divisors(n):  #約数列挙
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n%i == 0:
            divisors.append(i)
            if i != n//i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
    

divisors = make_divisors(M)
n = divisors[bisect_left(divisors, N)]
print(M//n)


Measured memory_bytes: 10828
n = int(input())
prime_numbers =[]
for i in range(n):
	a = int(input())
	if a == 2:
		prime_numbers.append(a)
	if a < 2 or a%2 ==0:
		None
	else:
		i = 3
		b = 0
		while i <= a**0.5:
			if a % i ==0:
				b = 1
				break
			i = i+2
		if b == 0:
			prime_numbers.append(a)

print(len(prime_numbers))


Measured memory_bytes: 5672
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
class Main{
  public static void main(String[] args) throws IOException
  {
    FastScanner fs = new FastScanner();
    long a = fs.nextLong();
    long b = fs.nextLong();
    long c = fs.nextLong();
    System.out.println(Math.min(Math.min(a+b,a+c),b+c));

  }
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 21204
/*
    * * * * *       *        * * * * * * * * * * * * * * * * * * * * * * * *     * * * * * * *               * *               * * * * * * * * * *
    * * * * *      * *       * * * * * * * * * * * * * * * * * * * * * *    *    * * * * * * *              * * *             * ** * * * * * * * * *
    * *           * * *            * *     * *     * *      * *          * * *   * * *       *             * * * *           * * * *       * *    * *
    * * * * *    * * * *           * *     * *     * *       * * * * * * *  * *  * * * * * * *            * * * * *         * *  * *       * * * * *
    * * * * *   * * * * *          * *     * *     * *        * * * * ** *   * * * * * * * * *           * * * * * *       * *   * * * *   * * * *
          * *  * * * * * *   * *   * *     * *     * *       * * * * * * *    * ** *     * * *          * * * * * * *     * *    * * * *   * *  * *
          * * * *       * *  * *   * *     * *     * *      * *          *     * * *     * * *         * *       * * *   * *     * *       * *   * *
    * * * * ** *         * * * * * * * * * * * * * * * * * * * * * * * * *      *  * * * * * * * * * ** *         * * * * *      * * * * * * *    * *
    * * * * * *           * ** * * * * * * * * * * * * * * * * * * * * * *       * * * * * * * * * * * *           * * * *       * * * * * * *     * *
*/

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <set>
#define ll long long
using namespace std;

int main(void)
{
    double x;
    cin>>x;
    if(x>=30)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }


    return 0;
}


Measured memory_bytes: 3160
import sys
import copy
def checkshojun(l):
    if all([l[i+1]>l[i] for i in range(len(l)-1)] ):
        return True
    else:return False
    
N = int(input())
P = [int(i) for i in input().split()]
if checkshojun(P):
    print("YES")
    sys.exit()

prev = P[0]
for i in range(1,N):
    if prev > P[i]:
        kouho = i -1  
        break
    prev = P[i]
    if i == N-1:
        print("NO")
        sys.exit()
k = P[kouho]

for t in range(kouho+1,N):
    li = copy.deepcopy(P)
    li[kouho] = li[t]
    li[t] = k
    if checkshojun(li):
        print("YES")
        sys.exit()
print("NO")

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

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;



int main()
{
	int a[3];

	rep(i, 3) cin >> a[i];
	sort(a, a + 3);
	cout << a[0];
	repc(i, 1, 2) cout << ' ' << a[i];
	cout << endl;

	return 0;
}



Measured memory_bytes: 3140
#include<stdio.h>
#include<algorithm>
using namespace std;
int aa[230];
main()
{
	int n;
	while(~scanf("%d",&n))
	{
		int i;
		for(i=0;i<n*2;i++)
		{
			scanf("%d",&aa[i]);
		}
		sort(aa,aa+2*n);
		int min,num=0;
		for(i=0;i<2*n;i=i+2)
		{
			min=aa[i]<aa[i+1]?aa[i]:aa[i+1];
			num+=min;
		}
		printf("%d\n",num);
	}
}

Measured memory_bytes: 128
import java.util.*

fun max(a: Int, b: Int): Int = if (a < b) b else a

fun main(args : Array<String>) {
    val (k, n) = readLine()!!.split(' ').map(String::toInt)
    val a = readLine()!!.split(' ').map(String::toInt)
    var d = 0
    for (i in 1 until n) {
        d = max(d, a[i] - a[i - 1])
    }
    println(k - max(d, a[0] + k - a[n - 1]))
}


Measured memory_bytes: 84492
import heapq

def main():
    n, m = map(int, input().split())
    dics = [{} for _ in range(n)]
    for _ in range(m):
        l, r, c = map(int, input().split())
        ky = r-1
        if ky in dics[l-1]:
            if c < dics[l-1][ky]:
                dics[l-1][ky] = c
        else:
            dics[l-1][ky] = c
    dist = [float("inf")]*n
    dist[0] = 0
    hq = []
    heapq.heappush(hq, [0, 0])
    idx = 0
    while len(hq) > 0:
        v, p = heapq.heappop(hq)
        if p < idx:
            continue
        if p == n-1:
            break
        for i in range(idx+1, p):
            if len(dics[i]) > 0:
                for ky in dics[i].keys():
                    if ky in dics[p]:
                        if dics[p][ky] > dics[i][ky]:
                            dics[p][ky] = dics[i][ky]
                    else:
                        if p < ky:
                            dics[p][ky] = dics[i][ky]
        idx = p
        for r in dics[p].keys():
            if dist[r] > v + dics[p][r]:
                dist[r] = v + dics[p][r]
                heapq.heappush(hq, [v + dics[p][r], r])
    if dist[n-1] == float("inf"):
        print(-1)
    else:
        print(dist[n-1])

if __name__ == "__main__":
    main()


Measured memory_bytes: 101256