akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    int n, k; cin >> n >> k;
    int m = n*(n+1)/2;
    vll a(n), b(n*(n+1)/2);

    rep(i, n) cin >> a[i];
    rep(i, n-1) a[i+1] += a[i];
    rep(i, n) b[i] = a[i];
    int t = n;
    rep(i, n-1){
        FOR(j, i+1, n){
            // pr(t);
            a[j] -= a[i];
            b[t++] = a[j]; 
        }
    }

    // prvec(b);

    vll c;
    ll ans = 0;

    for(int bit=63;bit>=0;bit--){
        c.clear();
        //bの各要素について、bitが立っているか
        rep(i, b.size()) {
            if((b[i]>>bit)&1){
                c.push_back(b[i]);
            }
        }

        if(c.size() >= k){
            ans += (1LL<<bit);
            b = c;
        }
    }

    pr(ans);
    return 0;}

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

int main() {
  int n, d;
  cin >> n >> d;

  int ans = n - (int)(n - (float)n / (2 * d + 1)); // 切り上げ
  cout << ans << endl;
//  vector<int> a(n);
//  rep(i,n) cin >> a[i];
//  ll x2 = 0;
//  rep(i,n) {
//    if (i%2) x2 -= a[i];
//    else x2 += a[i];
//  }
//  vector<int> ans(n);
//  ans[0] = x2/2;
//  rep(i,n-1) {
//    ans[i+1] = a[i]-ans[i];
//  }
//  rep(i,n) ans[i] *= 2;
//  rep(i,n) printf("%d%c", ans[i], i==n-1?'\n':' ');
  return 0;
}


Measured memory_bytes: 256
INF = 10**9
N = int(input())
h = list(map(int, input().split()))
cost = [INF] * N
cost[0] = 0
cost[1] = abs(h[1] - h[0])
for i in range(2, N):
  cost[i] = min(cost[i-1] + abs(h[i] - h[i-1]), cost[i-2] + abs(h[i] - h[i-2]))
print(cost[N-1])

Measured memory_bytes: 20500
n = int(input())
lst = list(input())

ans = {}
for i in range(1000):
    s = str(i).zfill(3)
    pos = 0
    is_exist = True
    for j in range(3):
        if s[j] in lst[pos:]:
            pos += lst[pos:].index(s[j]) + 1
        else:
            is_exist = False
            break
    if is_exist:
        ans[s] = 0
print(len(ans))


Measured memory_bytes: 9444
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

s = input()
chk_str = ""
chk = 0
for i in range(len(s)):
    if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
        chk_str += s[i]
    else:
        if chk < len(chk_str):
            chk = len(chk_str)
        chk_str = ""
if chk < len(chk_str):
    chk = len(chk_str)
print(chk)

Measured memory_bytes: 65468
n,m = map(int, input().split())

x = list(map(int,input().split()))

x.sort()

x_dif = []

for i in range(m-1):
    x_dif.append(x[i+1] - x[i])
    
x_dif.sort()

if m <= n:
    print(0)
else:
    print(sum(x_dif[:m-n]))

Measured memory_bytes: 13960
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn main() {
    input!{
        mut x: usize, y: usize,
    }

    let mut cnt = 0;

    while x <= y {
        cnt += 1;
        x *= 2;
    }

    println!("{}", cnt);
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> a(n); for (int i = 0; i < n; i++) cin >> a[i];
  map<int, int> odd, even;
  for (int i = 0; i < n; i++) if (i & 1) odd[a[i]]++;
  else even[a[i]]++;
  V< pair<int, int> > c1, c2;
  for (auto&& e : odd) c1.emplace_back(e.second, e.first);
  for (auto&& e : even) c2.emplace_back(e.second, e.first);
  sort(c1.rbegin(), c1.rend());
  sort(c2.rbegin(), c2.rend());
  if (c1.size() == 1) c1.emplace_back(0, -1);
  if (c2.size() == 1) c2.emplace_back(0, -2);
  int res = 1e9;
  for (int i = 0; i < 2; i++) for (int j = 0; j < 2; j++) {
    if (c1[i].second == c2[j].second) continue;
    res = min(res, n - c1[i].first - c2[j].first);
  }
  cout << res << '\n';
}

Measured memory_bytes: 6524
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    int N = Integer.parseInt(S[0]);
    int M = Integer.parseInt(S[1]);
    int p = 1000000007;
    boolean[] check = new boolean[N+1];
    
    for(int i = 0; i < M; i++){
      int n = Integer.parseInt(sc.nextLine());
      check[n] = true;
    }
    
    long[] dp = new long[N+1];
    dp[0] = 1;
    for(int i = 0; i < N; i++){
      if(check[i]){
        dp[i] = 0;
      }else if(i == N-1){
        dp[i+1] = (dp[i+1] + dp[i]) % p;
      }else{
        dp[i+1] = (dp[i+1] + dp[i]) % p;
        dp[i+2] = (dp[i+2] + dp[i]) % p;
      }
    }
    
    System.out.println(dp[N]);
  }
}

Measured memory_bytes: 95144
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

int main() {
    lint n, k;
    cin >> n >> k;
    vector<lint> a(n), f(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> f[i];
    }
    sort(all(a), greater<lint>());
    sort(all(f));
    lint cand_top = 1e+12, cand_bot = 0, cand_mid;
    while (cand_top > cand_bot) {
        lint need = 0;
        cand_mid = (cand_top + cand_bot) / 2;
        for (int i = 0; i < n; i++) {
            // temp:必要なマンパワー
            lint temp = cand_mid / f[i];
            need += max(a[i] - temp, (lint)0);
        }
        if (need <= k) {
            cand_top = cand_mid;
        } else {
            cand_bot = cand_mid;
        }
        if (cand_top - cand_bot <= 1) {
            break;
        }
    }
    // cand_botが実現できるか
    lint need = 0;
    for (int i = 0; i < n; i++) {
        // temp:必要なマンパワー
        lint temp = cand_bot / f[i];
        need += max(a[i] - temp, (lint)0);
    }
    if (need <= k) {
        cout << cand_bot << endl;
    } else {
        cout << cand_top << endl;
    }
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define all(a) (a).begin(),(a).end()
#define lb(s,x) lower_bound(all(s),x)-s.begin()
#define ub(s,x) upper_bound(all(s),x)-s.begin()
#define uniq(a) a.erase(unique(all(a)),a.end())
const int INF = 1e9;

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }


int main(void){
    string s;
    cin>>s;
    if(s.size() == 2) {
        cout<<s<<endl;
    }else{
        reverse(all(s));
        cout<<s<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int num[4010];//:= i/1000の数
int sum[4010];//:= i/1000までの数
int main(){
  int N;
  double q;
  cin >> N;
  vector<int> a(N);
  for(int i = 0;i < N;i++){
    cin >> q;
    a[i] = (q+0.00001)*1000;
    num[a[i]]++;
  }
  for(int i = 0;i < 4010;i++){
    if(i) sum[i] = sum[i-1]+num[i];
    else sum[i] = num[i];
  }
  for(auto x:a){
    if(x)cout << sum[x-1]*3 + num[x] - 1 << endl;
    else cout << num[0] - 1 << endl;
  }
}


Measured memory_bytes: 3320
N, K = map(int, input().split())
S = list(input())
a = 0
ta = 0
c = 1  # formernumber
if S[0] == '0':
    f = '0'
    F = 0
else:
    f = '1'
    F = 1
L = []
for i in range(1, N):
    if S[i] == f:
        c += 1
    else:
        L.append(c)
        f = S[i]
        c = 1
L.append(c)

if F == 0:
    L.insert(0, 0)
lenL = len(L)
if lenL % 2 == 0:
    L.append(0)
    lenL += 1
#print(L,lenL)
if lenL <= 2 * K + 1:
    print(N)
    exit()
ta = 0
for i in range(2 * K + 1):
    ta += L[i]
    a = ta
for i in range(0, lenL - 2 * K-1, 2):
    ta += -L[i] - L[i + 1] + L[i + 2 * K + 1] + L[i + 2 * K + 2]
    a = max(a, ta)
print(a)
# if F == 0 and len(L) <= 2 * K or F == 1 and len(L) <= 2 * K + 1:
#     print(N)
# elif F == 0:
#     if len(L) % 2 == 1:
#         L.append(0)
#     for i in range(2 * K):
#         a += L[i]
#     ta = a
#     for i in range(len(L)-2*K):
#         a += -L[i]-L[i+1]+L[i+2*K]+L[i+2*K+1]
#         ta = max(a,ta)
# L=[5,6,7,4,24,32]


Measured memory_bytes: 4792
//
// author  : Abhishek
//
#include <bits/stdc++.h>

#define ll long long
#define db double
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define all(x) x.begin(),x.end()
#define fo(i, n) for(i=0 ; i<n ; i++)
#define Fo(i, k, n) for(i=k ; i<n ; i++)

using namespace std;

const ll mod = 1000000007;
const ll N = 300005;  // array size
const ll inf = 10000000000000000;


void print(vector<ll> v) {
    ll i;
    fo(i, v.size())cout << v[i] << " ";
    cout << "\n";
}

vector<ll> read(ll n) {
    ll i;
    vector<ll> arr(n, 0);
    fo(i, n)cin >> arr[i];
    return arr;
}

vector<ll> read(ll n, ll k) {
    ll i;
    vector<ll> arr(n + k, 0);
    Fo(i, k, n + k)cin >> arr[i];
    return arr;
}

bool isEven(ll n) {
    return n % 2 == 0;
}

bool isOdd(ll n) {
    return n % 2 != 0;
}


void solve() {
    ll t;
    cin >> (t);
    while (t--) {

        ll i, j, k, n, m, p, q, x, y, a, b, l, r;


    }
}

int main() {

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

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

    ll i, j, k, n, m, p, q, x, y, a, b, l, r;


    cin >> a >> b;

    if(b == 1){
        cout<<0;
        return 0;
    }

    ll cur = a;
    ll ans = 1;

    while (cur < b) {
        ans++;
        cur += (a - 1);
    }

    cout << ans;


    return 0;
}




Measured memory_bytes: 3612
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
    ll m,l,r;
while(1){
   cin>>m>>r>>l;
   if(m==0)return 0;
   V<ll> a(m);
   for(int i=0;i<m;i++)cin>>a[i];
   sort(all(a));
   ll sum=0,ans;
   for(int i=m-l-1;i<m-r;i++){
         if(chmax(sum,a[i+1]-a[i]))ans=m-(i+1);
   }
   cout<<ans<<endl;
  }
}


Measured memory_bytes: 3120
#入力取得
n = int(input())
d = list(map(int, input().split()))

ans = 0

d.sort()



if n % 2 == 1:
    print(ans)
else:
    if d[n//2 - 1] == d[n//2]:
        print(ans)
    else:
        ans = d[n//2] - d[n//2 - 1]
        print(ans)


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

using namespace std;

int main(){
	long long n,k;double x;
	cin>>n>>k;
	x=k/2.0;
	if(n<=x){
		cout<<n;
		return 0;
	}
	n%=k;
	while(1){
		if(n<=x){
			cout<<n;
			return 0;
		}
		n=fabs(n-k);
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;

ll nCr(ll n, ll r) {
	if (r > n) { return 0; }
	if (r * 2 > n) r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
ll sumdigit(ll n) {
	ll dig = 0, sum = 0;
	while (n) {
		dig = n % 10;
		sum = sum + dig;
		n = n / 10;
	}
	return sum;
}



int main() {
	int n;
	int ar[100] = {};
	std::cin >> n;
	rep(i, n) {
		std::cin >> ar[i];
	}
	std::sort(ar, ar + n);
	std::cout << ar[n-1] - ar[0] << std::endl;
	return 0;
}

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

const int limit = 200010;
map<int, ll> num;
ll ans = 0LL, depth = 0LL;
vector<int> history;

void up() {
	history.push_back(-1);
	num[depth]++;
	depth++;
}

void down() {
	history.push_back(num[depth]);
	num[depth] = 0LL;
	depth--;
	ans += num[depth];
}

void roll_back(){
	const int cur = history.back();
	history.pop_back();
	if(cur == -1) {
		depth--;
		num[depth]--;
	} else {
		ans -= num[depth];
		depth++;
		num[depth] = cur;
	}
}

int main(void){
	string s;
	cin >> s;
	const int n = s.size();

	rep(i, n){
		if(s[i] == '(') {
			up();
		} else if(s[i] == ')') {
			down();
		} else {
			roll_back();
		}
		cout << ans << endl;
	}

}


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

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        double x = sc.nextDouble();
        double ans = 0;
        if (x * 2 <= a * a * b) {
            double c = 2 * x / (b * a);
            ans = Math.atan2(b, c);
        } else {
            double c = 2 * x / (a * a) - b;
            ans = Math.atan2(b - c, a);
        }

        System.out.printf("%.10f%n", ans / Math.PI * 180.0);
    }
}

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: 23252
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		final String abc = "ABC";
		final String arc = "ARC";

		Scanner scan = new Scanner(System.in);

		String s = scan.nextLine();

		String answer = s.equals(abc)
				? arc
				: abc;

		println(answer);
	}

	public static void println(Object target) {
		System.out.println(target);
	}
}


Measured memory_bytes: 26892
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;  
#define pb push_back
#define F first
#define S second
#define ppp pair<ll,pair<ll,ll>>
#define pp pair<ll,ll>
#define all(x) (x).begin(),(x).end()
#define pi 3.14159265358
#define MOD 998244353



int main()
{

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout); 
    // freopen("error.txt", "w", stderr); 
    // #endif
    
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);

     
   	 ll n,m,i,j,k,l;

   	 cin>>n>>k;

   	 cout<<min(n%k,k-n%k);

}



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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	int N, A, ans=0;

	cin >> N >> A;
	if( N % 500 <= A ){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}

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

sorted_A = sorted(A, key=lambda x: x[0])

amount = 0
num = 0
for price, max_num in sorted_A:
  if M > 0:
    if max_num < M:
      num += max_num
      amount += price * max_num
      M -= max_num
    else:
      num += M
      amount += price * M
      M -= max_num

print(amount)

Measured memory_bytes: 23528
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        System.out.println(collatz(s));
    }

    private static int collatz(int s) {

        Set<Integer> elems = new HashSet<>();

        int previous = s;
        int m = 1;

        while (!elems.contains(previous)) {
            elems.add(previous);
            previous = f(previous);
            m++;
        }
        return m;
    }

    private static int f(int s) {
        if (s % 2 == 0) return s / 2;
        else return (3 * s) + 1;
    }
}


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



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    ll x;
//    x=1ll << 59;
//    ll y=(1ll << 59) - 1ll;
//    cout<<((double)(x)==(double)(x-1))<<endl;
    char a[6],b,c,d;
    ll x,y,s=0;
    cin>>x>>y;
    for(int i=x;i<=y;i++){
        sprintf(a,"%d",i);
        if(a[0]==a[4]&&a[1]==a[3])s++;
    }
    cout<<s<<endl;
}


Measured memory_bytes: 3740
import math

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

na=a/0.08
nb=b/0.10

na_min=math.ceil(na)
na_max=math.ceil((a+1)/0.08)
nb_min=math.ceil(nb)
nb_max=math.ceil((b+1)/0.10)

if (na_max <= nb_min) or (nb_max <= na_min):
    print(-1)
else:
    if na_min > nb_min:
        print(na_min)
    else:
        print(nb_min)

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

const int mxN = 2e5;
vector<int> adj[mxN];
int component[mxN];

void dfs(int node, int comp) {
	component[node] = comp;
	for (int v : adj[node]) {
		if (!component[v]) {
			dfs(v, comp);
		}
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	int components = 0;
	for (int i = 0; i < n; i++) {
		if (!component[i]) {
			components++;
			dfs(i, components);
		}
	}
	vector<int> count(components + 1);
	for (int i = 0; i < n; i++) {
		count[component[i]]++;
	}
	cout << *max_element(count.begin(), count.end());
}



Measured memory_bytes: 24612
#include<iostream>
using namespace std;
int selectionSort(int* A,int N){ // N個の要素を含む0-オリジンの配列A
   int minj,k=0,j,i,v;
   for(i=0;i<N;i++){
       minj = i;
       for(j=i;j<N;j++){
            if(A[j] < A[minj]){
            minj = j;
            }
       }
        v=A[i];
        A[i]=A[minj];
        A[minj]=v;
        if(minj!=i){
            k+=1;
        }
    }
    return k;
}
int main(){
    int N,i,k;
    int A[1000];
    cin>>N;
    for(i=0;i<N;i++){
        cin>>A[i];
    }
    k=selectionSort(A,N);
    for(i=0;i<N-1;i++){
        cout<<A[i]<<" ";
    }
    cout<<A[N-1]<<endl;
    cout<<k<<endl;
    return 0;
}


Measured memory_bytes: 3108
#include <iostream>

using namespace std;

int main()
{
	int c[3][3];

	for(int i=0; i<3; i++)
		for(int j=0; j<3; j++)
			cin >> c[i][j];

	for(int i=0; i<2; i++)
	{
		if(c[i+1][0] - c[i][0] ==  c[i+1][1] - c[i][1]
		                                            && c[i+1][0] - c[i][0] ==  c[i+1][2] - c[i][2]);
		else
		{
			cout << "No" << endl;
			return 0;
		}
	}

	for(int j=0; j<2; j++)
	{
		if(c[0][j+1]-c[0][j] == c[1][j+1]-c[1][j]
		                                       && c[0][j+1]-c[0][j] == c[2][j+1]-c[2][j]);
		else
		{
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	return 0;
}

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

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

  vector<string> s(n);
  for(int i = 0; i < n; i++) cin >> s[i];

  for(int i = 0; i < n; i++) {
    sort(s[i].begin(), s[i].end());
  }

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

  // for(int i = 0; i < n; i++) cout << s[i] << endl;

  long long int ans = 0;
  for(int i = 0; i < n-1; i++) {
    int j = i+1;
    long long int cnt = 1;

    while(s[i] == s[j]) {
      cnt++;
      if(j < n-1)j++;
      else break;
    }
    i=j-1;
    // cout << "cnt: " << cnt << endl;
    if(cnt != 1) ans += cnt * (cnt-1) / 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e18;

int main(){
    ll N;
    cin >> N;
    if(N%2 == 1) {cout << 0 << endl; exit(0);}
    ll e[26];
    e[0] = 1;
    rep2(i, 1, 25) e[i] = 5*e[i-1];
    ll cnt[26];
    ll ans = 0;
    N /= 2;
    rep3(i, 25, 1){
        cnt[i] = N/e[i];
        ans += cnt[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int s=a+b+c;
    int cmax=max(max(a,b),c);
    s-=cmax;
    while(k--)
           cmax*=2;
    s+=cmax;
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()
	a := make([]int, n)
	for i := range a {
		a[i] = nextInt() - i - 1
	}

	sort.Sort(sort.IntSlice(a))
	b := a[n/2]
	ans := 0
	for i := range a {
		ans += abs(a[i] - b)
	}

	puts(ans)
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(int i=a;i<b;i++)
#define rlo(i,n) for(int i=n-1;i>=0;i--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define pr(a) {for(auto x:a)cout<<x<<" ";cout<<nl;}

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu ()
{
    cerr << endl;
}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest)
{
    cerr << arg << ' ';
    faltu(rest...);
}

void f()
{
    int x,n,p,a,b;
    bool m[105]= {0};
    cin>>x>>n;
    if(n==0)
    {
        cout<<x<<nl;
        return;
    }
    while(n--)
    {
        cin>>p;
        m[p]=1;
    }
    for(int i=x;; i++)
    {
        if(m[i]==0||i>100)
        {
            b=i;
            break;
        }
    }
    for(int i=x;; i--)
    {
        if(m[i]==0||i<0)
        {
            a=i;
            break;
        }
    }
    if(abs(x-a)<abs(x-b))
        cout<<a<<nl;
    else if(abs(x-a)>abs(x-b))
        cout<<b<<nl;
    else
    {
        if(a<b)
            cout<<a<<nl;
        else
            cout<<b<<nl;
    }
}

int main()
{
    su;
    ///tt
    f();
    return 0;
}


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

using namespace std;

int main(){
    char w[101];
    int chk[26]={0};
    scanf("%s",w);
    for (int i=0;i<strlen(w);i++){
        chk[w[i]-'a']++;
    }
    for (int i=0;i<26;i++) {
        if (chk[i]%2) {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


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


int main(){
    int n, l;
    cin >> n >> l;
    vector<string> ss(n);
    rep(i,n) cin >> ss[i];
    sort(ss.begin(), ss.end());
    rep(i,n){
        cout << ss[i];
    }
}


Measured memory_bytes: 256
#include <stdio.h>

#define MAX 1000000

int main(void) {
  int prime[MAX];
  int n, i, j, cnt;

  prime[0] = prime[1] = 0;
  for (i = 2; i < MAX; i++) prime[i] = 1;

  for (i = 2; i * i < MAX; i++)
    if (prime[i])
      for (j = 2 * i; j < MAX; j += i)
        prime[j] = 0;

  while (scanf("%d", &n) != EOF) {
    cnt = 0;

    for (i = 2; i <= n; i++)
      cnt += prime[i];

    printf("%d\n", cnt);
  }

  return 0;
}

Measured memory_bytes: 4500
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> answerList = new ArrayList();
		
		for(int i = 1; i <= n; i++) {
			int number = i;
			int count = 0;
			while(number >= 10) {
				number /= 10;
				count ++;
			}
			if(count == 0 || count % 2 == 0) {
				answerList.add(i);
			}
		}
		System.out.println(answerList.size());
		
		


		

		
		

		
		
	}	

}



Measured memory_bytes: 23124
//#include "SaveFuncs.cpp"

/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
//#define int long long
constexpr int INF = 2000000100;
constexpr int DIV = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> T divUp(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }

/*****/

int Main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	rep(i, N)	cin >> A.at(i);

	long double ret = 0.0;
	rep(i, N)
	{
		ret += 1.0 / A.at(i);
	}
	ret = 1.0 / ret;


	cout << fixed << setprecision(10);
	cout << ret;

	return 0;
}

/*****/

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

	Main();

	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader sc = new FastReader();
        String S = sc.next();
        if (S.charAt(0)==S.charAt(1) || S.charAt(1)==S.charAt(2) || S.charAt(2)==S.charAt(3)) {
            System.out.println("Bad");
        } else {
            System.out.println("Good");
        }
    }
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

int main() {
  int64_t n;
  std::cin >> n;

  std::vector<int64_t> a(100001, 0);

  for (int64_t i = 0; i < n; i++) {
    int64_t t;
    std::cin >> t;
    if (0 < t) {
      a[t - 1]++;
    }
    a[t]++;
    a[t + 1]++;
  }

  std::cout << *std::max_element(a.cbegin(), a.cend()) << std::endl;
  return 0;
}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

#define MAX_V 105

typedef pair<int, int> P; 


int main(){
    int n;
    cin >> n;
    vector<int> a(n);

    REP(i, n) cin >> a[i];
    sort(a.begin(), a.end());

    REP(i, n-1) {
        if(a[i] == a[i+1]){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <queue>
using namespace std;
 
vector<int> G[100001];
int S[100001], T[100001];
int Sc[100001], Tc[100001];
 
int main()
{
	int N, M, s, t;
	
	scanf("%d %d %d %d", &N, &M, &s, &t);
	
	for (int i = 0; i < M; i++){
		int src, dst;
		scanf("%d %d", &src, &dst);
		G[src].push_back(dst);
		G[dst].push_back(src);
	}
	
	for (int i = 1; i <= N; i++){
		S[i] = T[i] = 1000000000;
	}
	
	queue<int> q;
	
	S[s] = 0;
	
	for (q.push(s); q.size(); q.pop()){
		int x = q.front();
		Sc[S[x]]++;
		for (int i = 0; i < G[x].size(); i++){
			if (S[G[x][i]] > S[x] + 1){
				S[G[x][i]] = S[x] + 1; q.push(G[x][i]);
			}
		}
	}
	
	T[t] = 0;
	
	for (q.push(t); q.size(); q.pop()){
		int x = q.front();
		Tc[T[x]]++;
		for (int i = 0; i < G[x].size(); i++){
			if (T[G[x][i]] > T[x] + 1){
				T[G[x][i]] = T[x] + 1; q.push(G[x][i]);
			}
		}
	}
	
	long long ans = 0;
	for (int i = 0; S[t] - i - 2 >= 0; i++){
		ans += (long long)Sc[i] * Tc[S[t] - i - 2];
	}
	
	printf("%lld\n", ans);
	
	return (0);
}

Measured memory_bytes: 8216
import sys
import math

A, B = map(int, input().split())
C = math.ceil(A / 8 * 100)
while True:
    tax8 = C * 0.08
    if math.floor(tax8) > A:
        break
    tax10 = C * 0.1
    if math.floor(tax10) == B:
        print(C)
        sys.exit(0)
    C += 1
print(-1)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define repp(i,n) for(int i=1; i<n; i++)
#define int long long
using namespace std;
int gcd(int a, int b)
{
    if (a % b == 0) return b;
    return gcd(b, a % b);
}
signed main(){
  int n,m;
  while(cin >> n >> m){
    int a = gcd(n,m);
    int b = n*m/a;
    cout << a << " " << b << endl;
  }
  return 0;
}


Measured memory_bytes: 3080
#include<iostream>
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<stack>
#include<deque>
#include<vector>
#include<math.h>
#include<climits>
#include<map>

using namespace std;
#define ll long long

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll x;
	cin >> x;
	if (x >= -40 && x <= 40)
	{
		if (x >= 30)
		{
			cout << "Yes";
		}
		else
		{
			cout << "No";
		}
	}

}



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

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;

    int res = 0;
    int sum = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'I')
            sum++;
        else
            sum--;
        res = max(res, sum);
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
arr = []
ans = [0] * N
if N > 1:
    ans[0] = 1
for i in range(M):
    s, c = map(int, input().split())
    if s == 1 and c == 0 and N != 1:
        print(-1)
        exit(0)
    if s in arr and ans[s-1] != c:
        print(-1)
        exit(0)
    arr.append(s)
    ans[s-1] = c
print("".join([str(i) for i in ans]))


Measured memory_bytes: 3064
import sys
f = sys.stdin
n = int(f.readline())
h = list(map(int, f.readline().split()))
dp = [0]*n
dp[1] = abs(h[1] - h[0])
for i in range(2, n):
    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
print(dp[-1])


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

using namespace std; 
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>; 
#define INF (1<<(4*4-1))
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

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

   ll N,K;
   cin>>N>>K;
   vector<ll>A(N);
   for(int i=0;i<N;i++)cin>>A[i];

   ll n = max(K,*max_element(rng(A)));
   if(n==0)n=1;
   else n=log2(n)+1;
   vector<ll>memo(n);
   for(int i=0;i<n;i++){
      ll sum=0;
      for(int j=0;j<N;j++){
         if(1&(A[j]>>i))sum++;
      }
      memo[i]=sum;
   }
   vector<ll>cost0(n,0),cost1(n,0);
   for(int i=0;i<n;i++){
      cost0[i] = memo[i]*pow(2,i);
      cost1[i] = (N-memo[i])*pow(2,i);
   }

   //for(int i=0;i<n;i++)cout<<memo[i]<<" "<< 
   //                    cost0[i]<<" "<<N-memo[i]<<" "<<cost1[i]<<endl;

   vector<vector<ll> >dp(n+1,vector<ll>(2,-1));
   dp[0][0]=0;
   for(int i=0;i<n;i++){
      for(int j=0;j<2;j++){
         int x=j?1:(1&(K>>(n-i-1)));
         for(int k=0;k<=x;k++){
            if(dp[i][j]!=-1)dp[i+1][j||k<x] = max(dp[i+1][j||k<x],dp[i][j]+(k?cost1[n-i-1]:cost0[n-i-1]));
         }
      }
   }
   /*
   for(int i=0;i<=n;i++){
      for(int j=0;j<2;j++){
         cout<<dp[i][j]<<" ";
      }
      cout<<endl;
   }
   */
   cout<<max(dp[n][0],dp[n][1])<<endl;
   return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
	int x; cin >> x;
	for(int i = 1; i <= 1000000; i++){
		if(i * 100 <= x && x <= i * 105){
			cout << 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
	return 0;
}


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

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

    int count = 0;
    for(int i = 0;i < n;i++){
        if(s[i] == 'A' && i < n-2){
            if(s[i+1] == 'B' && s[i+2] == 'C') count++; 
        }
    }
    cout << count << endl;

    return 0;
}

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

int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}

int main() {
  long long int n,h,w;
  scanf("%lld",&n);
  scanf("%lld",&h);
  scanf("%lld",&w);
  long long int a,b,i;
  long long int ans = 0;
  for(i=0;i<n;i++) {
    scanf("%lld",&a);
    scanf("%lld",&b);
    if(h<=a && w<= b) {
      ans++;
    }
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;



int main(void)
{
    int N,M;
    cin >> N >> M;
    int Nmax = pow(2, N);
    vector<int> d(Nmax, INT32_MAX);
    d[0] = 0;

    for (int i = 0; i < M; i++)
    {
        int a, b, c, sbit;
        sbit = 0;
        cin >> a >> b;
        for (int i = 0; i < b; i++)
        {
            cin >> c;            
            sbit |= 1 << (c - 1); 
        }

        for (int i = 0; i < Nmax; i++)
        {
            if (d[i] != INT32_MAX && d[i | sbit] > d[i] + a)
            {
                d[i | sbit] = d[i] + a;
            }
        }
    }    

    if (d[Nmax - 1] == INT32_MAX)
    {
        d[Nmax - 1] = -1;
    }
    cout << d[Nmax - 1];
    return 0;
}

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX;
const ll MINF = LONG_LONG_MIN;
const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;


int main() {
    vector<int> terms(3);
    rep(i, 3)cin >> terms[i];
    sort(terms.begin(), terms.end());
    if (terms[2] == 7 && terms[1] == 5 && terms[0] == 5) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  if (k <= n - n / 2) {
    cout << "YES" << '\n';
  } else {
    cout << "NO" << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define ll long long int

int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<int>> g(n);
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        u--,v--;
        g[u].push_back(v);
    }
    vector<int> max_chain(n,-1);
    function<int(int)> dfs=[&](int node){
        if(max_chain[node]!=-1)return max_chain[node];
        max_chain[node]=1;
        for(auto v:g[node]){
            max_chain[node]=max(max_chain[node],dfs(v)+1);
        }
        return max_chain[node];
    };

    for(int i=0;i<n;i++){
        if(max_chain[i]==-1){
            max_chain[i]=dfs(i);
        }
        //debug(max_chain);
    }
    cout<<*max_element(max_chain.begin(),max_chain.end())-1<<"\n";
    return 0;
}

Measured memory_bytes: 14464
a,b,c,d=input().split()
a=int(a)
b=int(b)
c=int(c)
d=int(d)
l=[]
l.append(a*b/2)
if a/2==c and b/2==d:
    l.append(1)
else:
    l.append(0)
for i in l:
    print(i,end=" ")


Measured memory_bytes: 3060
#include <cstdlib>
#include <stdio.h>
#include <string>


int main()
{
	int rowmaxidx=3;
	char input[20];
	char output[20];
	char num[3][6];
	int out[3];
	int temp;
	
	fgets(input,sizeof(input),stdin);

	int idx=0;
	int row=0;
	for(int i=0;i<sizeof(input);i++){
		if(input[i] == '\0' || input[i] == '\n'){
			num[row][idx] = '\0';
			break;
		}
		if(input[i] != ' '){
			num[row][idx++] = input[i];
		}else{
			num[row][idx] = '\0';
			idx=0;
			row++;
		}
	}

	for (int i=0;i<rowmaxidx;i++){
		out[i] = atoi(num[i]);
	}

	for(int i=0;i<rowmaxidx;i++){
		for(int l=0;l<rowmaxidx;l++){
			if(i==l) break;

			if(out[i] < out[l]){
				temp = out[i];
				out[i] = out[l];
				out[l] = temp;
			}
		}
	}

	//result
	printf("%d %d %d\n", out[0], out[1], out[2]);

	return 0;
}




Measured memory_bytes: 2696
N=int(input())
A=[int(input()) for i in range(N)]
l=-1
ans=0
for i in range(N):
  if A[i]>l+1:
    print(-1)
    exit()
  elif A[i]==l+1:
    ans+=1
  else:
    ans+=A[i]
  l=A[i]
print(ans-1)
         

Measured memory_bytes: 59324
S=list(input())
T=list(input())
f=True
for i in S:
    if (ord(i)<97 or ord(i)>122) and f==True:
        f=False
for i in T:
    if (ord(i)<97 or ord(i)>122) and f==True:
        f=False
if len(S)+1!=len(T):
    f=False
else:
    for i in range(len(S)):
        if S[i]!=T[i]:
            f=False
if f==True:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 79816
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 610000;
const int K = 19;
const int mod = 1e9 + 7;
int f[N], invf[N], inv2, inv3;
int  lc[N], used[N], l[N], r[N], rc[N], cnt, a[N];
pair < int, int > t[N][2];
vector < int > g[N];
int binpow(int x, int y){
    if (y == 0) return 1;
    if (y % 2) return x * binpow(x, y - 1) % mod;
    int z = binpow(x, y / 2);
    return z * z % mod;
}
void dfs(int v){
    used[v] = 1;
    l[cnt] = min(v, l[cnt]);
    r[cnt] = max(v, r[cnt]);
    for (auto u: g[v]) if (!used[u]) dfs(u);
}
void build(int v, int tl, int tr){
    if (tl == tr){
        t[v][0] = {lc[tl], tl};
        t[v][1] = {rc[tl], tl};
        return;
    }
    int mid = (tl + tr) / 2;
    build(v + v, tl, mid);
    build(v + v + 1, mid + 1, tr);
    for (int i = 0; i < 2; i++){
        if (t[v + v][i].F < t[v + v + 1][i].F){
            t[v][i] = t[v + v][i];
        } else t[v][i] = t[v + v + 1][i];
    }
}
pair < int, int > getmin(int v, int tl, int tr, int l, int r, int x){
    if (l > r || l < tl || r > tr) return {1e15, 0};
   // cout << l << " " << r << endl;
    if (tl == l && tr == r) return t[v][x];
    int mid = (tl + tr) / 2;
    return min(getmin(v + v, tl, mid, l, min(r, mid), x), getmin(v + v + 1, mid + 1, tr, max(mid + 1, l), r, x));

}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n, d;
    cin >> n >> d;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        lc[i] = -i * d + a[i];
        rc[i] = i * d + a[i];
        l[i] = n + 1;
        r[i] = -1;
    }
    int ans = 0;
    build(1, 1, n);
    set < pair < int, int > > q;
    for (int i = 1; i <= n; i++){
        pair < int, int > l = getmin(1, 1, n, 1, i - 1, 0);
        pair < int, int > r = getmin(1, 1, n, i + 1, n, 1);
     //   cout << l.F << " " << l.S << "--" << r.F << " " << r.S << endl;
        if (lc[i] + r.F < rc[i] + l.F){
            if (q.find({min(i, r.S), max(i, r.S)}) != q.end()) continue;
            q.insert({min(i, r.S), max(i, r.S)});
            ans += lc[i] + r.F;
            g[i].pb(r.S);
            g[r.S].pb(i);
         //   cout << i << " " << r.S << endl;
        } else{
            if(q.find({min(i, l.S), max(i, l.S)}) != q.end()) continue;
            q.insert({min(i, l.S), max(i, l.S)});
            ans += rc[i] + l.F;
            g[i].pb(l.S);
            g[l.S].pb(i);
        //    cout << i << " " << l.S << endl;
        }
    }
    for (int i = 1; i <= n; i++){
        if (!used[i]){
            cnt++;
            dfs(i);
        }
    }
    for (int i = 1; i < cnt; i++){
        ans += getmin(1, 1, n, l[i], r[i], 0).F + getmin(1, 1, n, l[i + 1], r[i + 1], 1).F;
    }
    cout << ans;
}


Measured memory_bytes: 76544